Php htaccess mod_重写url的一部分以获取变量
我有一些类似的URL:Php htaccess mod_重写url的一部分以获取变量,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我有一些类似的URL: http://plutov.by/post/cubique_zf_jquery http://plutov.by/post/mysql_useful_queries 如何在Apache mod_的帮助下重写打开下一页 http://plutov.by/post/main?title=cubique_zf_jquery http://plutov.by/post/main?title=mysql_useful_queries 另外,这个新的重写规则是否适用于“一个入
http://plutov.by/post/cubique_zf_jquery
http://plutov.by/post/mysql_useful_queries
http://plutov.by/post/main?title=cubique_zf_jquery
http://plutov.by/post/main?title=mysql_useful_queries
谢谢。您可以在.htaccess中使用类似的内容:
RewriteRule ^post/(.*)$ post/main?title=$1 [L]
您应该在一个入口点重写规则之前保留此规则。如果将触发规则,则将完成重写规则查找(因为指定了[L]选项)
如果要在VirtualHost上下文中使用这些规则,使新的重写规则与“一个入口点重写”一起工作,可能需要对路径进行一些修改,请将
重写规则如下所示:
添加新查询字符串时,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]
-l
检查请求的URI是否不是符号墨水
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]