Title

Saturday, 7 February 2015

Ommitting a specific folder in htaccess redirect


Im trying to redirect a bunch of support files to a different support system except for any files that have the folder software_updates in them. the following is the rule that I wrote.

RewriteRule ^/support/.*(?!software_updates).*$ newurl_location [NC,L,R=301]

this excludes /support/software_updates/ but not /support/product/software_updates Im trying to exclude any URL that has software_updates anywhere in the URL after support.

Answer

Try:

RewriteRule ^/support/(?!.*software_updates) newurl_location [NC,L,R=301]

I don't have Apache handy to test it, but it should work.

Answer2

rocketdoctor, I have tested this and believe that it is what you're looking for (please note the changes in the / and the .* )

RewriteRule ^support/(?!.*?software_updates) newurl_location [NC,L,R=301]

You were nearly there.

First off, you don't need the initial /

You don't want .*(?!software_updates).*, because this will match software_updates. Why? The dot-star eats the whole string, then, at the end, you have the assertion that software_updates is not next. And of course this is true.

Answer3

This should do the trick.

RewriteRule ^/support/(?!.*software_updates).*$ newurl_location [NC,L,R=301]

See Demo

No comments:

Post a Comment