Regex can';t在我的mod_重写代码时逃逸点(.)
我需要转换我网站的以下地址:Regex can';t在我的mod_重写代码时逃逸点(.),regex,.htaccess,mod-rewrite,Regex,.htaccess,Mod Rewrite,我需要转换我网站的以下地址:http://mysite.com/do.php?id=123.W456/789进入http://mysite.com/123.W456/789 通过以下.htaccess文件,我几乎实现了这一崇高目标 DirectoryIndex mysite.php 重新启动引擎 RewriteRule^([A-Za-z0-9\/&46;]+)?$mysite.php?id=$1[L] 其中和#46是一个(点)字符的代码 这样的url字符串http://mysite.com/12
http://mysite.com/do.php?id=123.W456/789
进入http://mysite.com/123.W456/789
通过以下.htaccess文件,我几乎实现了这一崇高目标
DirectoryIndex mysite.php
重新启动引擎
RewriteRule^([A-Za-z0-9\/&46;]+)?$mysite.php?id=$1[L]
其中和#46
是一个
(点)字符的代码
这样的url字符串http://mysite.com/123W456/789
(即将其重写为http://mysite.com/do.php?id=123W456/789
)
但不重写带有点字符的url字符串-http://mysite.com/123.W456/789
有人能帮忙吗?我们使用
\.
来转义htaccess文件中的点字符,而不是它的HTML实体。使用HTML实体会使它认为您允许使用&
、#
和代码>字符而不是
字符。如果您有其他错误,请尝试检查您的Apache错误日志。当我使用重写规则([A-Za-z0-9\/\.]+)?$mysite.php?id=$1
而不是echo$\u GET['id']
i getmysite.php
显然,如果您允许所有字母数字字符、斜线和点,那么您的重写规则将几乎匹配所有内容。你真的应该更具体一些,使用类似于mysite.com/id/123.W456/789
的东西。Apache给您的错误是什么?[Wed Oct 19 22:42:28 2011][error][client 87.252.227.84]文件不存在:/var/www/admin/data/www/site.com/10fhsdert,referer:http://site.com/10fhsdert/sad-无dot[星期三,2011年10月19日22:43:28][error][client 87.252.227.84]文件不存在:/var/www/admin/data/www/site.com/10fhsdert
-在10fhsdert后加点