I have created 301 redirection code for my website. Following is my code to all my categories to redirect to new url
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^testsite.com/categories/city/$1 [nc]
rewriterule ^(.*)$ http://www.testsite.com/$1 [r=301,nc]
I want to redirect http://www.testsite.com/categories/city/pune to http://www.testsite.com/Pune
Let me know my code is correct or not?
Thanks
It’s not correct. The
%{HTTP_HOST}is only the host that’s provided in theHost:header of the request. It’s not going to include any path info. You could separate that condition into 2 things: