Forum Moderators: phranque
washingtondc.mydomain.com/
austin.mydomain.com/stp
boston.mydomain.com/stp/61073929.html
obviously, these are just examples, the 'washingtondc', 'stp', '6107929' could be anything.
So if my site is mydomain.com, I would like to access by
mydomain.com/city.php?city=washingtondc
mydomain.com/categ.php?city=austin&categ=stp
mydomain.com/ad.php?city=boston&categ=stp&ad=61073929
Could someone please suggest the mod rewrite rules.
I think I need to mention that this domain is a sudomain to my main domain, domain.com meaning that it is the same url as mydomain.domain.com. The hosting provider allows subdomain
if i have have /home/username/pubic_html/mydomain.
Everyone will be accessing it via mydomain.com or www.mydomain.com. I am assuming that I will have to put .htaccess file in my subdomain root directory.
I have tried the following httpd.config file as suggested by Jim that did not help (Jim only first rule works www.mydomain.com goes to mydomain.com. If I ignore the first rule, second rule works but only with www.mydomain.com but not with cityname.mydomain.com
# start htaccess file
# Code for use in root-level .htaccess file
Options +FollowSymLinks
RewriteEngine on
#
# Remove leading www to standardize domain name 'branding', improve
# search engine results, and simplify the rules that follow.
RewriteCond %{HTTP_HOST} ^www\.([^.]+\.)?mydomain\.com
RewriteRule (.*) [%1mydomain\.com...] [R=301,L]
#
# Bypass following rules for non-page resources
RewriteRule ^robots\.txt$ - [L]
RewriteRule \.(gif¦jpg)$ - [L]
#
# Case: Local URL-path is empty (city only)
RewriteCond %{REQUEST_URI}!^/city\.php$
RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com
RewriteRule ^$ /city.php?city=%1 [L]
#
# Case: Local URL-path includes category only
RewriteCond %{REQUEST_URI}!^/city\.php$
RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com
RewriteRule ^([^/]+)/?$ /city.php?city=%1&categ=$1 [L]
#
# Case: Local URL-path includes cat and ad
RewriteCond %{REQUEST_URI}!^/city\.php$
RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com
RewriteRule ^([^/]+)/([^/]+)/?$ /city.php?city=%1&categ=$1&ad=$2 [L]
#end htaccess file