我尝试将我的网址从“www.example.com/article.php?title=blub”重写为“www.example.com/blub”
但它不起作用。
RewriteEngine on
RewriteRule (.*)\.html$ article.php?title=$1
此代码有效,但只能使用html扩展名。
但是,我不想使用此扩展程序。
提前致谢。
答案 0 :(得分:0)
这应该适合你:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /wiki/
# we don't want to rewrite existent directories
RewriteCond %{REQUEST_FILENAME} !-d
# we don't want to rewrite existent files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)$ article.php?title=$1 [L]
您的代码存在的问题是,它不会检查文件是否存在,所以当您重定向它时\.html
它没有进入循环,因为它不关心{{1}是否存在。
通过评论谈到,OP发现他的文件不在他根据问题article.php
描述的根文件夹上,而是在名为www.example.com/article.php?title=blub
的子文件夹上。