Forum Moderators: phranque
but the problem is I have about 100 subdomains, and I need to use it for every single subdomain. I could upload the .htaccess file to each sudirectory, but I'm sure there must be an easier way to handle it.
I'd like to have one .htaccess file in my root directory that will handle all subdomains.
thanks.
If your subdomains are rewritten to subdirectories of your main account, then it should work. If they are aliased, then you could remove that alias and use a rewrite instead. It all depends on *how* you map your subdomains to subdirectories.
The thing to remember is that in order for an .htaccess file on your root directory to be processed, it must be in the server filepath of the requested resource (page, image, script, etc.). The server traverses that path and executes each .htaccess file it finds as it resolves the URL to a filename.
Jim
If you are doing the subdomain->subdirectory rewrite in httpd.conf, then you' also want to move this new rule into httpd.conf; otherwise it will be bypassed (And note the subtle difference in the RewriteRule pattern between .htaccess and httpd.conf - the pattern in httpd.conf must start with a slash).
RewriteRule ^([^/]+)/something-([^.]+)\.html$ /$1/index.php?pg=$2 [L]
Jim
I decided to look up that forum, and I found something like this:
rewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com
at [webmasterworld.com...]
Then I thought I could use it somehow in my .htaccess:
rewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com
RewriteRule ^something-(.*).html$ /index.php?pg=$1
I don't have access to the httpd.conf file. All I can do is to operate on the .htaccess file. I was tring to avoid uploading that .htaccess file one by one to my subdomains.
Now I have something like this:
subdomain.domain.com/index?pg=1
but I need
subdomain.domain.com/index1.html
Hope this make it simple.
thanks!