tags:

views:

27

answers:

2
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. What modification is needed in htaccess to allow read . characters?

+2  A: 

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.

Korbinian
A: 

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

s_broderick
That's not true at all.
Jordan
Interesting, that's what I've always heard. How do you rewrite files with URLs with no extension? That would be helpful to know. I was always told it cannot be done.
s_broderick