【发布时间】:2014-04-08 18:28:13
【问题描述】:
我的“fs”文件夹中的 .htaccess 文件中有以下内容:
RewriteEngine on
RewriteRule ^(.*)$ index.php [L]
基本上我希望将所有 url 发送到 index.php 文件,但我需要在我的 url 中保留尾部斜杠。 RewriteRule 似乎总是从 url 中删除尾部斜杠,我需要保留它们。
http://example.com/fs/path/ 被重定向到 http://example.com/fs/path
如何防止尾部斜杠被删除?我需要保留斜杠。有什么想法可以做到这一点吗?
编辑 这是父 .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^auth(.*)$ auth.php?$1 [L]
RewriteRule ^file/(.*)$ file.php?path=/$1 [L]
RewriteRule ^(.*).css$ css.php?path=/$1 [NC]
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
【问题讨论】:
-
此规则不会(不能)删除尾部斜杠。你还有其他规定吗?
-
这是我在这个文件夹中的整个 .htaccess 文件。我在父文件夹中有另一个 .htaccess 文件。这会导致问题吗?如果是,有没有办法忽略父文件夹中的那个?
-
你能显示父 .htaccess 代码吗?
-
刚刚将父 .htaccess 添加到原始帖子
-
好吧好吧。
/fs/path是一个真实的目录吗?它也有 .htaccess 吗?
标签: php regex apache .htaccess mod-rewrite