我想将我的htaccess修改为:
我最终得到了这个:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !app\.php$
RewriteRule ^(.*)\.php?$ /app.php/ [R=301,L]
[...]
</IfModule>
但是这会在http://example.com/sqdlkqjsdlsqk.php
等测试网址上产生404这里有什么问题?
此致
答案 0 :(得分:1)
您应该在app.php
之后使用此规则而不使用斜杠:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/app\.php$ [NC]
RewriteRule ^(.+)\.php$ /app.php [R=301,L,NC,NE]
确保在测试此更改之前清除浏览器缓存。
答案 1 :(得分:1)
检查一下。确保清除缓存。
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
# When mod_rewrite is not available, we instruct a temporary redirect of
# the start page to the front controller explicitly so that the website
# and the generated links can still be used.
RedirectMatch 302 ^/$ /app.php/
# RedirectTemp cannot be used instead
</IfModule>
</IfModule>