Mod_rewrite rule: if the URL contains a specific string

My client continues to edit the navigation structure on the website, which leads to some mod_rewrite problems. How can I make this rule:

RewriteRule ^studios/about-studios/artist-noticeboard noticeboard2.php?section=studios&subSection=studio-artists [L]

if the url contains "noticeboard"? Like this:

RewriteRule ^IF CONTAINS 'noticeboard' noticeboard2.php?section=studios&subSection=studio-artists [L]

Any pointers are welcome!

+3
source share
1 answer

Try the following:

RewriteCond %{REQUEST_URI} !/noticeboard2\.php$
RewriteRule noticeboard noticeboard2.php?section=studios&subSection=studio-artists [L]

This rule will rewrite any request that contains a “message board” in the URL to embed signboard2.php in the same directory.

+8
source

Source: https://habr.com/ru/post/1735037/


All Articles