简体   繁体   中英

htaccess 301 redirect doesn't work

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

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM