I have the following htaccess rule:
Redirect 301 / http://www.example.co.uk/blog/
On an old blog at http://blog.example.co.uk/
that should be redirecting ALL urls from this old blog to the new one.
However if I have anything in the path: e.g. http://blog.example.co.uk/2015/test-post
then it redirects to http://www.example.co.uk/blog/2015/test-post
How do I make it so that it doesn't keep the path and just redirects to the domain.
You need to use RedirectMatch
for that:
RedirectMatch 301 ^ http://www.example.co.uk/blog/
Make sure to test this in a new browser.
Or if you want to strip off any existing query string also then use mod_rewrite
:
RewriteEngine On
RewriteRule ^ http://www.example.co.uk/blog/? [L,R=301]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With