English 中文(简体)
分子-重物和GET参数
原标题:mod_rewrite and GET parameters

我有一个网站,使用页体如下:

index.php?page=X&id=Y

For example, for a blog it will be

index.php?page=blog&id=65

照片

index.php?page=picture&id=26

我正试图制定改写规则,使人们能够利用我的场地。 com/页面或我的现场.com/page/id,但在通过两个参数时,会遇到问题。

出于某种原因,它把我转往右页,然后立即重载同一页,没有参数,即将装上<编码>index.php?page=blog&id=65<>/code>,然后立即重载<代码>index.php?page=blog ,这是无用的。

The code I m using:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ /index.php?page=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)$ index.php?page=$1&id=$2 [L]

任何建议都将受到赞赏。 感谢。

问题回答

解决这一问题的最佳途径是将all的请求转至一个路由页(通常为index.php文档),并将其列入实际要求的文件。 它使你能更好地控制你在什么地方的转头,并且使规则比雷斯特很容易实现更为复杂。

至于你的具体问题。 可以是 Java,可以重载你的窗户,也可以是你重新贴上<代码>Location:的头盔。

Read up on the mod_rewrite documentation and specifically on the [QSA] (query string append) flag. Without this, the rewrite engine will dump existing parameters if you specify new ones in your replacement string. With it, it will append the old ones.





相关问题
Using SimplePie with CodeIgniter and XAMPP

I am using CodeIgniter 1.7.2 with XAMPP 1.7.2 on a Windows computer. I am trying to make use of SimplePie. I followed all the instructions I could find: a copy of simplepie.inc is in my applications/...

Multiple Sites with common files

I have developed over 50 sites that all use the exact same files other than CSS and IMAGES, I currently duplicate the files each time I create a new site and upload different css and images. What ...

http server validation

I finish a litle http server, writing from scratch. I would like to be sure that my imlementation is conforme to the HTTP specifications. W3C give us tools for HTML/XML conformance, but i see nothing ...

热门标签