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.
精彩评论