Forum Moderators: phranque

Message Too Old, No Replies

.htaccess subdomain rerouting

Really stuck

         

Zerxer

8:42 am on Dec 17, 2007 (gmt 0)

10+ Year Member



What I'm trying to do is route a subdomain to the root using a temporary redirect so that the subdomain still appears in the URL bar. Is this possible? I keep trying it and it keeps turning it into a 301 when I attempt to go to [root.com...] from a .htaccess file in the subdomain's directory.

Here's a variety of different rules I have tried (separately):

RewriteRule ^(.*) /home/root/public_html/index.php?x=$1 [L]

RewriteRule ^(.*) [root.com...] [L]

RewriteRule ^(.*) ../index.php?x=$1 [L]

Again, those were all in the subdomain's .htaccess file, not root.

I really don't know what to do, or if what I'm trying to do is even possible. The 2nd one actually works, but it does a 301 rather than a 302. The 1st and 3rd ones don't work at all, errors.

[edited by: Zerxer at 8:43 am (utc) on Dec. 17, 2007]

Zerxer

5:07 am on Dec 18, 2007 (gmt 0)

10+ Year Member



No help available for this? Trying to set something up. :(

g1smd

4:43 pm on Dec 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If the subdomain URL still needs to appear in the browser URL bar, then you need a rewrite.

A 301 or 302 redirect would change the URL that the user sees.

You need a rewrite here. The rewrite takes the requested URL and then translates that into an internal filepath to fetch that content from.

Post this question in the Apache forum, and you'll get a rapid response.

Look through the thousands of examples already posted first, as I think many people would have already asked the same or similar question.

Zerxer

7:46 pm on Dec 19, 2007 (gmt 0)

10+ Year Member



Thanks. I might ask there but I think I've realized that I can no longer do what I wanted to do. My site uses AJAX for most things and I don't think it'd let you access the scripts in the root via AJAX when the location in your URL bar is the subdomain, because they don't match. I'm not sure if it wouldn't care anymore or not if I had the rewriterule. I guess I'll ask that there.