Mobile app version of vmapp.org
Login or Join
Angela700

: Modify existing htaccess rewrites to not match particular URLs Trying to rewrite only particular URL's, for example:- (1) I want to rewrite:- http://www.example.com/keyword-1 http://www.example.com/keyword-1/sub-keyword

@Angela700

Posted in: #Htaccess #Regex #UrlRewriting

Trying to rewrite only particular URL's, for example:-

(1) I want to rewrite:-
www.example.com/keyword-1 http://www.example.com/keyword-1/sub-keyword www.example.com/keyword-1/?p=50

(2) I don't want to rewrite:-
www.example.com/keyword-1-product

This is what I have so far...

RewriteRule ^/?alfred-victoria$ /brands/alfred-victoria/ [R=301,L]
RewriteRule ^/?alfred-victoria/(.*)$ /brands/alfred-victoria/ [R=301,L]


These handle (1) above but not (2), URL's that start with the keyword in /alfred-victoria-blah-blah are also getting rewritten.

How can I modify the rules above to exclude these URL's. I thought the dollar ($) indicated end of string and ignore anything else after this point?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Angela700

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ogunnowo487

As you suggest, neither of those two rules can be redirecting /alfred-victoria-blah-blah. So, either there is something else that is performing this redirect, or a previous (erroneous) 301 redirect has been cached - clear the browser cache etc.

Also, confirm whether this is a 301 redirect and not a 302 or some other 3xx (could help indicate where this is happening).

It would seem that an old redirect was cached on this occasion.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme