Reputation: 577
I have many urls such as:
mydomain.com/location/illinois/
mydomain.com/location/wisconsin/green-bay/
mydomain.com/location/new-york/
I have removed the word location and replaced it with: /blog/category/
so those urls should now be:
mydomain.com/blog/category/illinois/
mydomain.com/blog/category/wisconsin/green-bay/
mydomain.com/blog/category/new-york/
I am trying to get this done with one rewrite rule. But the one I created is not working. Can you tell me what is wrong with it?
Here is what I tried:
RewriteEngine On
RewriteBase /
RewriteRule ^/location(/.*|)$ /blog/category/$1 [L,NC,R=301]
Upvotes: 2
Views: 400
Reputation:
Nice try, you just need to drop the opening slash which is not included in .htaccess matches:
RewriteEngine On
RewriteRule ^location(/.*|)$ /blog/category$1 [L,NC,R=301]
No need for the RewriteBase either. And you had doubled up the slash before the category which you're already capturing.
Upvotes: 2