我有一些类似的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]
- 标志
QSA
Apache文档 !-l
检查所请求的URI是否不是符号墨迹
您可以在.htaccess:中使用类似的东西
RewriteRule ^post/(.*)$ post/main?title=$1 [L]
在一个入口点重写规则之前,您应该保留此规则。如果规则将触发,则重写规则查找将完成(由于指定了[L]选项)
如果您想在VirtualHost上下文中使用这些规则,则可能需要对路径进行一些修改