[英]301 redirect to get rid of the slash
在htaccess中是否有办法将所有页面重定向到/没有任何内容。 所以例如我想要这个
http://somesite.com/something/ ==> http://somesite.com/something
http://somesite.com/another_thing/ ==> http://somesite.com/another_thing
http://somesite.com/page3/ ==> http://somesite.com/page3
http://somesite.com/page4/ ==> http://somesite.com/page4
page3,page4,something,another_thing都是每个目录中都有一个index.php文件......这就是我处理它的方式
在我的htaccess中,我正在摆脱/由此
DirectorySlash Off
RewriteCond %{REQUEST_FILENAME}/index\.php -f
RewriteRule ^(.+)$ /$1/index.php [NC,QSA,L]
我基本上只是因为seo原因而想要301重定向,所以即使它们被缓存,每个人都会在非斜杠页面上结束。提前知道。
这个
如果要从包含它们的所有请求中删除尾部斜杠,请尝试:
RewriteRule ^/(.+)/$ /$1 [R]
请参阅URL重写指南并查找Canonical URL 。 此外,请注意DirectorySlash Off
指令的文档和安全警告。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.