htaccess redirect without the path

Cameron

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.

anubhava

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]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related