Reputation: 15
post edited with better current example.
I am looking for the best way to redirect my subdomains to subdirectories which do not really exist as subfolders.....
in a nutshell, the script I am using for a website allows for setting up geographic regions as subdomains..... but each region MUST have a unique subdomain and I really do not want to have 3-level subdomains (state, city, neighborhood) for my regions and the "big boys" in my niche all opt to use a single subdirectory (like /neighborhood-city,state/) so I am looking for the best way to point my subdomains to subdirectories, although they do not actually exist....
I currently have this in the htaccess as a rewrite:
RewriteRule ^/?([0-9]+)/([^./\\"'?#]+)\.html$ index.php?a=5&b=$1 [QSA,L] ##category
which rewrites to the url to: mydomain/cat#/catname.html
I want the URL/links to have this non-existing "region" subdomain-as-subdirectory added after the /catname/ but not sure how to modify this rewrite so that instead of having:
subdomain.mydomain/cat#/catname.html
I would have:
mydomain/cat#/catname/subdomain(value).html
Upvotes: 0
Views: 279
Reputation: 7073
The not found error is normal because you redirect your subdomains to nonexistents directories, which are not rewrited. Besides your redirection, you have to rewrite these directories so that the server knows where it can find the real files. So, try this code :
RewriteEngine On
RewriteRule ^([^/]+)/(.*)$ http://$1.domain.com/$2 [L]
Of course, you have to change this path to the good.
Upvotes: 2