Msg#: 4521261 posted 9:36 pm on Nov 21, 2012 (gmt 0)
Hey Guys, I have been racking my brain on this one for a while and after days of trying/breaking stuff, I figured I come ask the pros here:
I have about 100 subdomains that are no longer on my dedicated Apache server, all that is listed is the main domain and I have turned on wildcard through records. The issue I am having is I am missing some code to make all those old non used subdomains when typed in or followed by an old link somewhere work properly and can't find it anywhere.
Right now no matter what sub.domain is typed in it forwards to mydomain.com and that is fine for sub.domains that never existed but I would like to say if this certain sub1.mydomain.com is hit that used to be a live link take it to the new page that would be something like mydomain.com/sub1-page-here/
Here is the code I have in the .htaccess file I think I am missing the code that actually makes these work there is about 100 of them:
Msg#: 4521261 posted 5:19 am on Nov 22, 2012 (gmt 0)
I am a total newb with .htaccess rules but I know Rewrite is on as there is other simple redirects in there and W3 cache rules, gzip and want not. There is no pattern to the sub.domains as one could be blue.mydomain.com and another one could be tool.mydomain.com etc... Do you guys have an example of what would be best and work for me?
Msg#: 4521261 posted 7:26 am on Nov 22, 2012 (gmt 0)
I know Rewrite is on as there is other simple redirects in there and W3 cache rules, gzip and want not
Do any of them use mod_rewrite? Of course you've got it installed; that's not the worry. But unlike most things in Apache it isn't inherited. You have to turn on the RewriteEngine in each separate htaccess that uses it. Your "simple redirects" may be using mod_alias ("Redirect" or "RedirectMatch" by that name rather than "RewriteRule...").
it would be more efficient if you could make the pattern in the RewriteRule more specific.
I don't think he can. He's redirecting entire subdomains. So unless each one has its own unique set of directory names, you can't do much in the Rule.
Although come to think of it: Do the subdomains contain anything besides pages? Images, stylesheets, scripts and so on? If not, you can constrain all your RewriteRules to requests in / or .html (or whatever your extension is). In fact even if there did use to be other stuff in the subdomains, I can't imagine you'll get a lot of independent requests for them. So you can say something like
where [?] means that g1smd or someone like him is going to come along and explain how you rewrite to a different host-- in this case to your primary domain instead of the requested subdomain-- without having it turn into a redirect. You don't want to end up with two redirects if you can help it.