Reputation: 541
This are my urls
http://test.aDomain.com/x-61bff
http://test.aDomain.com/x-ssmJhs54as65d4
http://test.aDomain.com/x-115545454
my rewrite rules
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ http://%1/$1 [L,R=301]
RewriteRule ^create-account create-account.php [L]
RewriteRule ^account account.php [L]
RewriteRule ^impress impress.php [L]
RewriteRule ^(x\-[a-zA-Z0-9]+) redirect.php?code=$1 [L]
The result is
http://test.aDomain.com/redirect.php
But why? it should be
http://test.aDomain.com/redirect.php?code=x-61bff
i dont get it ... can anybody help?
Upvotes: 0
Views: 13
Reputation: 31274
mainly because you got the regex wrong:
the /
between the host-name and the path is really part of the path (e.g. it is /x-61bff
instead of x-61bff
). however, your regex matches only an x
at the very beginning, thus /x-61bff
will never match.
the minus-sign has only a special meaning within square brackets (e.g. [A-Z]
); outside it is just another character, there is no need to escape it
so your rewrite-rule really should look like:
RewriteRule ^/(x-[a-zA-Z0-9]*) redirect.php?code=$1 [L]
Upvotes: 1