Trying to redirect to my php script using htaccess


I have gone over and over this but I can not get it to work.

I am trying to match this:


and send it to:


So I am using:

Options +SymLinksifOwnerMatch 
RewriteEngine On

RewriteCond %{HTTP_HOST} ^[.+][0-9]+-[\\.0-9_-a-z]+\\.html$ [NC]
RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteRule ^[\\.0-9,-a-z]+\\[0-9]+)-[\\.0-9_-a-z]+\\.html$ [NC,QSA,L]

But it is not working.

Because this first block is not catching the incoming url,
my second block gets it and sends it to the wrong page.

My second block should only match:


And re-direct to :

It uses:

RewriteCond %{HTTP_HOST} ^(.+)$ [NC]
RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteRule ^.*$ [NC,QSA,L]

This second block works - BUT it should not be excepting
any url with data coming after “” … but it does.

Because when the first block fails, the second is doing
a re-direct ( but to the wrong page )

Can anyone see where I have gone wrong ?



Hi Jekko!

First, you are in need of some information about how to correctly write code for mod_rewrite. Therefore, you might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It’s helped may members and should help you, too.

[noparse] =>[/noparse]

WHY in the world would you use villarentfethiye as a subdomain? Does it even exist? Unless you REALLY need it, the first thing I would do is strip useless information from the URL (so you can actually hide the link with the query string). Then the code would be trivial:

# .htaccess in DocumentRoot

# strip useless domain information
RewriteCond %{HTTP_HOST} !^simpg\\.net$ [NC]
RewriteRule .?{REQUEST_URI} [L]

# Redirect to deliverable link
RewriteRule ^([0-9]+)-[a-z]+\\.html$ info1.php?a=$1 [L]

Please note that the {HTTP_HOST} variable does not contain a / nor a URI.

If you follow the above code, you’ll KNOW why your code was not working, i.e., {HTTP_HOST} and the subdomain you captured clearly did not contain digits.