Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 301重定向以删除斜杠_Php_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

Php 301重定向以删除斜杠

Php 301重定向以删除斜杠,php,.htaccess,mod-rewrite,redirect,Php,.htaccess,Mod Rewrite,Redirect,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://s

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
第3页,第4页,一些,另一些都是目录,每个目录中都有一个index.php文件。。。我就是这样处理的

在我的htaccess中,我正在通过这个来摆脱

DirectorySlash Off
RewriteCond %{REQUEST_FILENAME}/index\.php -f 
RewriteRule ^(.+)$ /$1/index.php [NC,QSA,L]
我基本上想301重定向只是为了搜索引擎优化的原因,所以每个人都会在非斜杠页面上结束,即使他们被缓存。提前感谢


如果要从包含尾部斜杠的所有请求中删除尾部斜杠,请尝试:

RewriteRule   ^/(.+)/$  /$1   [R]

请参阅并查找规范URL。此外,请注意的文档和安全警告。

是否在我的htaccess之前或之后。它属于同一个.htaccess文件。我会把它放在另一个重写条件/规则之前,这样下面几行就更清楚了。