开发者

.htaccess url rewrite issue with dot

I want to create my url structure like:: facebook i.e. facebook.com/?pageid=122 For which I am using htaccess mod rewrite as:

RewriteRule ^([a-zA-Z_\-]+)/?([a-zA-Z0-9\-=&_@]*)$ /$1.php?$2 [QSA,L]

so I may translate pages like site.com/home/?pageid=22 into site.com/home.php?pageid=22

The code above works fine except that if I try to add dot like

RewriteRule ^([a-zA-Z_\-]+)/?([a-zA-Z0-9\-=&_@\.]*)$ /$1.php?$2 [QSA,L]

The .htaccess break开发者_JS百科s. I need dot so I may pass emails too i.e. site.com/home/?email=sohaib.dmc@gmail.com

Please help


Try to remove the backslash before the dot. Since it's not considered as a special character inside brackets in a POSIX regular expression.


You need scape the question mark because it's a special character:

RewriteRule ^([a-zA-Z_\-]+)/\?([a-zA-Z0-9\-=&_@\.]*)$ /$1.php?$2 [QSA,L]

The question mark makes the preceding token in the regular expression optional. E.g.: colou?r matches both colour and color. http://www.regular-expressions.info/optional.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜