Forum Moderators: phranque

Message Too Old, No Replies

subdomain mod rewrite

         

solarisdev

12:49 am on Mar 14, 2009 (gmt 0)

10+ Year Member



Hi,
I have url like this:
[hello.world.com...]
and what I actually need is to rewrite this to:
[world.com...]

If someone is willing to help that would be great.

Regards

jdMorgan

2:34 pm on Mar 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried a search for "rewrite subdomain to script"? We've had several recent threads on this subject.
You can make the search more specific by adding "RewriteCond HTTP_HOST RewriteRule" to it.

Also, in addition to information about how to get the most from this forum, our Forum Charter contains links to useful resources, and our Apache Forum Library contains several tutorial threads. See the links at the top left of this page.

We ask that you review these resources, and then post your best-effort code as a basis for discussion; We are glad to help you write your code and get it working, but we cannot provide a "free code-writing service" here.

Thanks,
Jim

solarisdev

11:45 pm on Mar 14, 2009 (gmt 0)

10+ Year Member



Hi Jim,
Thanks for reply, I will do as you advice me.

Regards

solarisdev

4:18 pm on Mar 16, 2009 (gmt 0)

10+ Year Member



Hi Jim
I have tried to create this .htaccess. This is what I have so far:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.smething\.com
RewriteRule ^$ /newspaper.php?nespaperid=%2&v=$1 [QSA,L]

When i type like: [test.something.com...] I just got default page with displayed IP address but when I type [something.com...] I got newspaper.php page, that should go for 1st case but not for second.
Is there maybe something I should set in control panel?

Regards

jdMorgan

6:18 pm on Mar 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you want to exclude "www.example.com" from being rewritten, then add

RewriteCond %{HTTP_HOST} !^www\.example\.com

Jim

eeek

10:16 pm on Mar 16, 2009 (gmt 0)

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



I just create a virtual domain for the subdomain to do that. Then there's no need to play with RewriteCond at all.