4

My client keeps editing the structure of the navigation in the website, which is leading to some mod_rewrite issues. How could i make this rule:

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

to work if the url contains "noticeboard"? Like this:

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

Any pointers welcome!

Tomalak
  • 332,285
  • 67
  • 532
  • 628
v3nt
  • 2,845
  • 6
  • 36
  • 50

1 Answers1

9

Try this:

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

This rule will rewrite any request that contains “noticeboard” in the URL path to noticeboard2.php in the same directory.

Gumbo
  • 643,351
  • 109
  • 780
  • 844
  • And what do I have to specify if I DON'T want to rewrite id url contains noticeboard – Capacytron Sep 04 '12 at 08:01
  • 1
    @Sergey Invert the `RewriteRule` pattern with `!`. – Gumbo Sep 04 '12 at 18:59
  • Thanks, I've already solved related problem. It's here: http://stackoverflow.com/questions/12258698/apache-tomcat-apache-httpd-mod-proxy-mod-rewrite-form-post-data – Capacytron Sep 05 '12 at 10:14
  • ...maybe obvious, but I would also point out that this rewrites any request that contains "noticeboard" UNLESS it exactly equals /noticeboard2.php as per the RewriteCond. – Wes Grant Apr 30 '15 at 16:00