php - htaccess mod_rewrite 部分 url 到 GET 变量

标签 php apache .htaccess mod-rewrite

我有一些这样的 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]

关于php - htaccess mod_rewrite 部分 url 到 GET 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9229398/

相关文章:

.htaccess - htaccess - 将目录重定向到同名文件

javascript - "site requires javascript"作为关键字从分析器返回

php - 如何对 foreach 循环的输出进行分组?

Apache 无法访问 Tomcat : AH00957, AH00959 和 AH00896

Apache Hadoop 2.6 : Pseudo Distribution Mode Setup

performance - 请解释这个 Symfony 与 Zend Framework 2 的性能结果

apache - 如何使用htaccess从www重定向到https www?

php - 在盲代码中使用 mysql_real_escape_string

PHP 重定向,保留 POST

php - .htaccess 重定向,url 中包含 mysql 内容