.htaccess 重写为存在文件名但省略扩展名的 uri
.htaccess rewrite to uri where filename exists but extension omitted
我 运行 遇到了一个奇怪的问题,我的 .htaccess 未能将其传递给 index.php。根据我当前的重写规则,如果我转到 mysite.com/abc123,它会正确重定向到 index.php,将 /abc123 传递给要处理的 index.php 查询字符串。
但是,如果我访问 mysite.com/test,我会看到一个 Apache Not Found 错误页面。我期待它进入 index.php 并作为查询字符串通过测试。
如果我访问我的网站。com/test。php 它会按预期正常加载该文件。
我的文件结构如下所示:
/
|- index.php
|- test.php
|- .htaccess
这是我当前的 .htaccess 文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} /([a-z\-A-Z]+)
RewriteRule .* index.php?/[=11=] [L,QSA]
</IfModule>
# END WordPress
<FilesMatch "\.(html|css|js|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=259200, proxy-revalidate"
</FilesMatch>
从 Options
中删除 MultiViews
。
或者如果您找不到 Options
指令所在的位置,您可以添加:
Options -MultiViews
我 运行 遇到了一个奇怪的问题,我的 .htaccess 未能将其传递给 index.php。根据我当前的重写规则,如果我转到 mysite.com/abc123,它会正确重定向到 index.php,将 /abc123 传递给要处理的 index.php 查询字符串。
但是,如果我访问 mysite.com/test,我会看到一个 Apache Not Found 错误页面。我期待它进入 index.php 并作为查询字符串通过测试。
如果我访问我的网站。com/test。php 它会按预期正常加载该文件。
我的文件结构如下所示:
/
|- index.php
|- test.php
|- .htaccess
这是我当前的 .htaccess 文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} /([a-z\-A-Z]+)
RewriteRule .* index.php?/[=11=] [L,QSA]
</IfModule>
# END WordPress
<FilesMatch "\.(html|css|js|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=259200, proxy-revalidate"
</FilesMatch>
从 Options
中删除 MultiViews
。
或者如果您找不到 Options
指令所在的位置,您可以添加:
Options -MultiViews