Forum Moderators: phranque

Message Too Old, No Replies

.htaccess Rewrite Help

         

rlibbey

3:06 pm on Dec 13, 2007 (gmt 0)

10+ Year Member



I am trying to do a very simple rewrite, but have never done one before and am having issues. Here is what I am trying to accomplish:

[subdomain1.domain.com...] -> [subdomain2.domain.com...]

I do not want the subdomain1 variable to be a wildcard however. The subdomains are already defined, so I can just create a different .htaccess rewrite for each one.

Don't ask me what I have tried so far because I have just modified other rewrite code and have gotten virtually nowhere thus far. :P

I would appreciate any help. Thanks so much in advance!

jdMorgan

4:40 pm on Dec 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nonetheless, it would be very helpful if you would post your best effort so far and describe how you tested it and how the results differed from your expectations -- to serve as a basis for discussion. Otherwise, about all we can do is to suggest that you try searching WebmasterWorld for "Rewrite subdomain subdirectory RewriteCond HTTP_HOST [google.com]" and similar strings, to find many previous threads on this subject.

For more information, see our forum charter [webmasterworld.com] and the documents cited therein.

Jim

rlibbey

7:10 pm on Dec 13, 2007 (gmt 0)

10+ Year Member



Here is what I have tried, resulting in a 500 Internal Server Error:

#Internally rewrite "testing" subdomain to /testing subdirectory within another subdomain (subdomain2)
rewriteCond $1!^testing/
rewriteCond %{http_host} ^testing\.domain\.com
rewriteRule (.*) subdomain2\.domain\.com/accutag/$1 [L]

The tricky part is the fact that I am trying to rewrite to a completely seperate subdomain. Is this even possible?

Is there anything i can do within a conf file on the server to accomplish this?

rlibbey

8:10 pm on Dec 13, 2007 (gmt 0)

10+ Year Member



I made a mistake in my previous post. Here is the correct one, with the correction in bold:

#Internally rewrite "testing" subdomain to /testing subdirectory within another subdomain (subdomain2)
rewriteCond $1!^testing/
rewriteCond %{http_host} ^testing\.domain\.com
rewriteRule (.*) subdomain2\.domain\.com/testing/$1 [L]

jdMorgan

8:22 pm on Dec 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you change the subdomain or domain, then this is by definition an external redirect, and the change will appear in the client browser's address bar.

Then we have the question of whether these subdomains are all hosted in the same "account space" on the same server; If so, then subdomains are meaningless, because they essentially 'disappear' once the request is inside the server, leaving only (possibly) filespace differences.

Is this your only rewriterule? Do you have others that work? If not, have you set up and enabled mod_rewrite with the Options and RewriteEngine directives?

But the main question is "What, overall, are you trying to accomplish with this? If you can answer in terms of URLs (as seen in your browser) and filespace (as defined in your server) that will lead to an efficient exchange.

Also, if you can examine your server error log, the information listed there related to this error may be very useful to all.

Jim