我在折断的链接检查器网站上检查了我的WordPress主题,它给了我一个损坏的URL。
请参阅:
http://www.esmedicare.com/locations.html ( parent page: http://www.esmedicare.com/ )
http://www.esmedicare.com/laser-treatments/locations.html ( parent page: http://www.esmedicare.com/laser-treatments/ )
与/location.html的链接转到404页,我想将这些页面重定向到他们的父母页面。即,只需从URL中删除/location.html,然后将其重定向到支架中提到的父url。
我添加了代码:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/locations.html$ /$1/ [L,R=301]
到我的.htaccess文件,现在一些/location.html
页面正在重定向到他们的父页面,但并非全部。
请解决我的问题...我只想从URL中的最后删除/location.html
。
如果您需要包括Web根(/
),则需要使Slash可选:
RewriteRule ^(.*?)/?locations.html$ /$1/ [L,R=301]