Reputation: 750
Live site- http://www.marchingmonk.com
I add 301 redirect on my htaccess file but that doesn't not work. Code-
Redirect 301 /home http://www.marchingmonk.com
When you click on the "home" button of the website, the user is not being redirected to http://www.marchingmonk.com, the user is redirected to http://www.marchingmonk.com/home, this creating a duplicate content issue. That site is created with a CMS(i don't have any knowledge on that CMS), so i want to make a redirection by htaccess file but that not works.
Any idea how to fix that issue.
Full code of htaccess file-
#old php Handler
RewriteEngine On
RewriteCond %{HTTP_HOST} ^marchingmonk\.com$
RewriteRule ^(.*) http://www.marchingmonk.com/$1 [R=301]
RewriteCond %{HTTP_HOST} ^(www.)?marchingmonk.com$
RewriteRule ^([^\.]+)/?$ index.php?id=$1 [QSA,L]
RedirectMatch 301 ^/home/?$ http://www.marchingmonk.com
Upvotes: 1
Views: 2561
Reputation: 785146
You can use RedirectMatch
for its regex capabilities:
RewriteEngine On
RewriteRule ^home/?$ http://www.marchingmonk.com/? [L,NC,R=301]
RewriteCond %{HTTP_HOST} ^marchingmonk\.com$
RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?marchingmonk\.com$ [NC]
RewriteRule ^([^.]+?)/?$ index.php?id=$1 [QSA,L]
Upvotes: 2