I am trying to write htaccess file that would convert
http://subdomain.my-tld.com/
to
http://my-tld.com/file.php?var=subdomain
Notice the hyphen in the tld.
Here's the htaccess I am using:
Options +FollowSymLinks
Options -Indexes
RewriteEngine On
# Rewrite sub domains.
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^www\.my-tld\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.my-tld\.com$ [NC]
RewriteRule ^(.*)$ /file.php?var=%2 [QSA,L]
I am using the very same code for another domain in the very same server and it is working great, but it is not for this domain. I am guessing that the problem is with the hyphen in this domain.
Any suggestions?
For me, these rules make the server return "Internal Server Error", and the error log will print
I'm not sure why it works for another domain as you said, but just try adding this condition before the final RewriteRule:
Make it pass the url alreay get param "var".