开发者

htaccess rewrite problem

RewriteRule ^a/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([0-9]+)$
    /var/www/vhosts/mydomin.com/httpdocs/search.php?searchtext=$1&locationtext=$2&page=$3
    [QSA]

I want to pass http://www.mydomain.com/searchtext=jobs&locationtext=A.G.sBosRoad&page=1, but I'm getting an error. I'm guessing this error is due to the . characters. 开发者_如何学GoWhat modification is needed in htaccess to allow read . characters?


Your regex for locationpart doesn't accept dots, as you say. Change the character class to include \.:

RewriteRule ^a/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_\.-]+)/([0-9]+)$ /var/www/vhosts/mydomin.com/httpdocs/search.php?searchtext=$1&locationtext=$2&page=$3 [QSA]

or, more generally, if your script doesn't have problems with it:

RewriteRule ^a/([^/]*)/([^/]*)/(\d+)$ /var/www/vhosts/mydomin.com/httpdocs/search.php?searchtext=$1&locationtext=$2&page=$3 [QSA]

That will accept any string without slashes for locationtext and searchtext, even the empty string, and still redirect to your search script.


.htcaccess only accepts files that end in a proper extension such as .html or .php.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜