Hi everybody, I have viewing the city names in my website like the following structure - www.mydomain.com/state/city/ Here is the ,htaccess code- RewriteRule ^([^/]*)/([^/]*)/$ city.php?state=$1&city=$2 [NC] But actually, I'm looking for to use wildcard subdomains that will rebuild the city names like the following structure- city.mydomain.com/state/ Can you help me? I just need the htaccess rewrite code.
Try this, but I'm not sure if this is something you can achieve with htaccess alone. <IfModule mod_rewrite.c> Options +FollowSymLinks Options +Indexes RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !www.mydomain.com$ [NC] RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).mydomain.com [NC] RewriteRule (.*) mydomain.com/city.php?state=$1&city=$2 [NC] [L] </IfModule> Code (ApacheConf): With your DNS provider, configure the wildcard. *.mydomain.com. IN A 1.2.3.4 (Obviously adjust the DNS to your needs)