开发者

Htaccess Rewrite Rule with a PERIOD

I need a rule that when someone types

domain.com/finddomain.com it points to domain.com?q=finddomain.com

Very simple, yet the period in "finddomain.com" is causing my rule to fail.

My rule is:

RewriteRule开发者_StackOverflow中文版 ^([A-Za-z0-9.]+)(/)?$ index.php?q=$1

The "." screw it up.

Any help is much appreciated!


You have to escape the period with a backslash \. because the period stands for any character.

So your RegEx ^([A-Za-z0-9.]+)(/)?$ does actually match every string.. It should be ^([A-Za-z0-9\.]+)/?$ (or ^([A-Za-z0-9\.]+\.[a-zA-Z]+)/?$ to match only domains with a TLD).


try to escape the dot, since dot in regular expressions denote "anything"

cheers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜