Php mod_重写问题-将页面路由到查询字符串
我需要帮助我重写一个网站的模版 假设我有这个网站 我希望能够在/to路由到page.php之后产生任何值,如下所示Php mod_重写问题-将页面路由到查询字符串,php,apache,mod-rewrite,Php,Apache,Mod Rewrite,我需要帮助我重写一个网站的模版 假设我有这个网站 我希望能够在/to路由到page.php之后产生任何值,如下所示 http://example.com/value1 http://example.com/value2 指 http://example.com/page.php?id=value1 http://example.com/page.php?id=value2 分别为 但是,当我指向“管理员”时,不会转到该页面 我试过了 RewriteEngine on RewriteCon
http://example.com/value1
http://example.com/value2
指
http://example.com/page.php?id=value1
http://example.com/page.php?id=value2
分别为
但是,当我指向“管理员”时,不会转到该页面
我试过了
RewriteEngine on
RewriteCond $1 !^(admin)
RewriteRule ^(.*)$ /page.php?id=$1 [L]
但它不起作用。有什么想法吗?这有什么帮助吗
$1
在出现这种情况时不可用。我相信您正在寻找的是:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^admin/.*
RewriteRule ^(.*)$ page.php?id=$1 [L]
此规则导致所有不以admin/
开头的内容转到/page.php
。我不相信%{param}是可选的。使用RewriteBase/
意味着您不需要在/admin
和/page.php
上使用prepend/
;如果使用/page.php
而不是page.php
如果您有访问服务器值的方法,那么最终规则可以是:
RewriteRule . page.php [L]
您可以在
请求\u URI
中找到被调用的url,注意到您在$1中是正确的,首先处理规则,然后检查条件。他们可以参考reg ex的结果
RewriteRule . page.php [L]