Reputation: 481
I have two different styles of URLs (below)
domain.com/shop/post/post-name
domain.com/shop/?p=123
I want to redirect both of these to domain.com/blog/post/post-name
or domain.com/blog/post/123
Currently, I am using:
RewriteCond %{REQUEST_URI} post/([^.]+)$
RewriteRule ^(.*)$ https://www.itl.uk.net/blog/$1 [R,L]
Which redirects the first URL but i'm not sure how to include a rule to redirect both
Upvotes: 1
Views: 31
Reputation: 785196
You can have these rules in shop/.htaccess
, just below RewriteEngine On
line:
RewriteEngine On
# to handle /shop/post/post-name
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^post/.+$ /blog/$0 [L,NC,R=301,NE]
# to handle /shop/?p=123
RewriteCond %{QUERY_STRING} ^p=(\d+)$ [NC]
RewriteRule ^/?$ /blog/post/%1? [L,NC,R=301,NE]
Upvotes: 1