我有一些这样的 URL:
http://plutov.by/post/cubique_zf_jquery
http://plutov.by/post/mysql_useful_queries
如何在 Apache mod_rewrite 的帮助下打开下一页?
http://plutov.by/post/main?title=cubique_zf_jquery
http://plutov.by/post/main?title=mysql_useful_queries
此外,这个新的重写规则是否适用于“一个入口点重写”?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
谢谢。
最佳答案
要使新的重写规则与“一个入口点重写”一起工作,请像这样设置您的rewriteRules
:
QSA
标记是必需的,因为您要添加新的查询字符串。
RewriteEngine On
RewriteRule ^(post)/([\w\d\-]+)/?$ $1/main?title=$2 [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . index.php [L]
- Flag
QSA
Apache Docs . !-l
检查请求的 URI 不是符号墨水。
关于php - htaccess mod_rewrite 部分 url 到 GET 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9229398/