我真的不太擅长写htaccess。对我来说看起来像胡言乱语。 :-)
所以我们不要做的就是删除URL的.php扩展名。
这是我们的脚本
RewriteEngine On
RewriteBase /
## hide .php extension snippet
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1/ [R,L]
RewriteRule ^help/([A-Za-z0-9_]+)/?$ help.php?artid=$1 [NC,L] # Process parrots
RewriteRule ^signature/([A-Za-z0-9_]+)/?$ signature.php?artid=$1 [NC,L] # Process parrots
RewriteRule ^signatures/([A-Za-z0-9_]+)/?$ signatures.php?artid=$1 [NC,L] # Process parrots
# add a trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteRule . %{REQUEST_URI}/ [L,R=301]
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
我真的在这里找不到问题。 问题是,当我f.x转到localhost / secure / profil时,它给了我一个404未找到。但是,当我将所有.htaccess注释掉并转到localhost / secure / profil.php时,它会起作用。
打开htaccess时的确切网址如下:
http://localhost/secure/profil/
也许有人可以看到我在这里做错了吗?
任何帮助将不胜感激!
亲切的问候!