这就是我想要实现的。我想重定向像这样的
http://www.example.com/news/news-seo-title-with-unicode-maybe.html
http://www.example.com/news.php?seo_url=news-seo-title-with-unicode-maybe.php
这是我在我的htaccess文件
中写的内容Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)'.html$ $1.php?seo_url=$2 [L]
我被重定向到news.php,但没有在$_GET变量。我的htaccess代码有什么错误吗?
您可以使用:
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^.]+)'.html$ $1.php?seo_url=$2 [L,NC,QSA]
选项MultiViews
由运行在mod_rewrite
之前的Apache's content negotiation module
使用,并使Apache服务器匹配文件的扩展名。所以/file
可以在URL中,但它将服务于/file.php
。