Forum Moderators: phranque

Message Too Old, No Replies

another rewrite problem

         

ajBerns

6:46 pm on Aug 31, 2004 (gmt 0)

10+ Year Member



Hope this one goes to Jim as soon as possible.

This is my first post so I would like to have Jim address this because I've read so much inquiries answered by him with positive feedback.

Ok, here is my rewrite code written at .htaccess file:

RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com [NC]
Rewriterule ^dir/index\.html [mysubdomain.mydomain.com...] [R=301,L]

I get to see the resulting URL correctly but not the contents that I am expecting.

I actually get to see the index page of my website root directory.

how should I fix this?

Thanks a lot in advance.

jdMorgan

8:30 pm on Aug 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ajBerns,

Welcome to WebmasterWorld!


RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com [NC]
RewriteRule ^dir/index\.html [mysubdomain.mydomain.com...] [R=301,L]

I get to see the resulting URL correctly but not the contents that I am expecting.


If the resulting URL you see is correct, then the rule you posted is working fine. But you will have to use mod_rewrite or some other method to tell the server what directory you want it to use when it receives requests for mysubdomain.mydomain.com.

Normally, you'd have a second ruleset that would 'map' subdomain requests to a subdirectory, something like:


RewriteCond %{HTTP_HOST} ^mysubdomain\.mydomain\.com
RewriteRule (.*) /mysubdomain_subdirectory/$1 [L]

Jim

ajBerns

6:31 pm on Sep 1, 2004 (gmt 0)

10+ Year Member



Anyway, I tried this one,

RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com [NC]
RewriteRule ^mysub/paths/index\.php?id=1$ [dirtydomain.mydomain.com...] [R=301,L]

but this didn't worked. I mean, I still see the same URL. I need to change the URL as [dirtydomain.mydomain.com...] Or more precisely, I need to change the URL dynamically for each user on my site. Just like [newuser1.mydomain.com,...] [newuser2.mydomain.com...etc...] of course, this goes whenever the 'id' attribute in the index.php page changes value...

Any idea?

jdMorgan

9:52 pm on Sep 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm having a hard time understanding what you want to do.

If you want to rewrite ^mysub/paths/index\.php?id=<any_username> to http://dirtydomain.mydomain.com/<any_username>

Then the rule would be:


RewriteCond %{QUERY_STRING} id=([^&]+)
RewriteRule ^mysub/paths/index\.php$ http://dirtydomain.mydomain.com/%1? [R=301,L]

Jim

ajBerns

7:45 pm on Sep 3, 2004 (gmt 0)

10+ Year Member



Actually, this is what I wanted to rewrite:

^mysub/paths/index\.php?id=<any_username> to [<any_username>.mydomain.com...]

Thus, I wanted that every page request having this form: index.php?id=<somevalue> would display this URL: [<somevalue>.mydomain.com...] having the original contents...

Just that currently, the URL is correct but the contents is wrong (displays the contents of the index page in my root directory)

Hope, I explained it well... :)

Thanks in advance!

jdMorgan

8:56 pm on Sep 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> the URL is correct but the contents is wrong (displays the contents of the index page in my root directory)

In that case, the problem is not with the rewrite rule you are talking about here; Whatever code you use to 'map' subdomains into subdirectories on your site is broken (or missing).

Jim