mod_rewrite的问题 - 路由页面查询字符串 [英] mod_rewrite Problem - Routing pages to query string

查看:96
本文介绍了mod_rewrite的问题 - 路由页面查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助我的的mod_rewrite 作为一个网站即时通讯目前正在研究。

I need help with my mod_rewrite for a site im currently working on.

让我们说我有这个网站 http://example.com

Let's say I have this site http://example.com

和我希望能够在/路由后作出的任何值喜欢page.php低于

And I want to be able to make any value after the / to route to page.php like below

http://example.com/value1

http://example.com/value2

为指向

http://example.com/page.php?id=value1

http://example.com/page.php?id=value2

,分别为。

不过,该页无法路由时指出IM为admin

But, not route to that page when im pointing to "admin"

http://example.com/admin/

我试过

RewriteEngine on
RewriteCond $1 !^(admin)
RewriteRule ^(.*)$ /page.php?id=$1 [L]

但它不工作。有什么想法?

But it isn't working. Any thoughts?

推荐答案

$ 1 目前还无法提供条件的时间。我相信你正在寻找的是接近:

$1 is not available at the time of the Condition. I believe what you are looking for is close to:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^admin/.*
RewriteRule ^(.*)$ page.php?id=$1 [L]

该规则使一切没有开头管理​​/ 进入 /page.php 。我不相信%{}参数是可选的。使用的RewriteBase / 意味着你不必有prePEND / /管理员 /page.php ;它实际上可能故障,如果您使用 /page.php 而不是 page.php

this rule causes everything not starting with admin/ to go to /page.php. I don't believe the %{param} is optional. Using RewriteBase / means you do not to have prepend / on /admin and /page.php; it may actually fault if you use /page.php instead of page.php

如果你有访问服务器值的手段,那么最终的规则可以是:

If you have means of accessing the server values, then the final rule can be:

RewriteRule . page.php [L]

您可以找到所谓的URL的 REQUEST_URI

You can find the called url in the REQUEST_URI

这篇关于mod_rewrite的问题 - 路由页面查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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