我希望我的所有域名都能重写并且看起来很棒。例如:
example.com/blog.php?article=the-name-of-article 成为 example.com/blog/the-name-of-article
所以我想将.php?article =改成/
我当前的.htaccess文件如下:
Options +FollowSymLinks -MultiViews
rewriteengine on
RewriteBase /
## Hide .php extension
## To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
但所有这一切都是放弃.php
我一直在寻找,但我只是想听听每个人如此轻松地完成这件事。
答案 0 :(得分:1)
RewriteRule ^blog/(.*)$ blog.php?article=$1 [QSA,L]