【发布时间】:2021-07-24 22:58:28
【问题描述】:
我的 .htaccess 遇到了一个奇怪的问题,它无法将它传递给 index.php。使用我当前的重写规则,如果我转到 mysite.com/abc123,它会正确重定向到 index.php,将 /abc123 传递给 index.php 处理的查询字符串。
但是,如果我访问 mysite.com/test,我会看到 apache Not Found 错误页面。我希望这会转到 index.php 并作为查询字符串通过测试。
如果我访问 mysite.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?/$0 [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>
【问题讨论】:
标签: apache .htaccess url mod-rewrite url-rewriting