URL的htaccess的mod_rewrite的一部分GET变量 [英] htaccess mod_rewrite part of url to GET variable

查看:134
本文介绍了URL的htaccess的mod_rewrite的一部分GET变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的一些网址:

  • http://plutov.by/post/cubique_zf_jquery
  • http://plutov.by/post/mysql_useful_queries
  • http://plutov.by/post/cubique_zf_jquery
  • http://plutov.by/post/mysql_useful_queries

我如何使用Apache的mod_rewrite的帮助下打开下一个页面?

How can I with help of Apache mod_rewrite open the next pages?

  • http://plutov.by/post/main?title=cubique_zf_jquery
  • http://plutov.by/post/main?title=mysql_useful_queries
  • http://plutov.by/post/main?title=cubique_zf_jquery
  • http://plutov.by/post/main?title=mysql_useful_queries

此外,将与一个入口点重写?

Also, will be this new rewrite rule work with "one entry point rewriting"?

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

感谢。

推荐答案

为了与一个入口点重写的新重写规则的工作,有你的的规则集这样的

To make the new rewrite rule work with "one entry point rewriting", have your rewriteRules like this:

QSA 标志的必须的作为要添加一个新的查询字符串。

The QSA flag is mandatory as you are adding a new query string.

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的文档
  • ! - 。→检查所请求的URI是不是象征性的油墨
    • Flag QSA Apache Docs.
    • !-l checks that the requested URI is not a symbolic ink.
    • 这篇关于URL的htaccess的mod_rewrite的一部分GET变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆