所以我将article.php?id=10
缩短为article/10
。这一切似乎都很好。但我几乎不知道它破坏了我的其他网址。因此,对于http://localhost/forgot/
,我必须转到http://localhost/forgot/index
才能真正达到它。这是我正在使用的
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^article/([0-9]+)$ article.php?id=$1
RewriteRule ^([^\.]+)$ $1.php [NC,L]
我想转到http://localhost/forgot/
而不是http://localhost/forgot/index
/任何想法?
答案 0 :(得分:1)
你的规则如下:
Options -MultiViews
DirectoryIndex index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^article/([0-9]+)$ article.php?id=$1 [L,QSA,NC]
# rewrite from /dir/file/ to /dir/file.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ /$1.php [L]