homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

fake virtual subdomain

 10:23 am on Oct 17, 2013 (gmt 0)


On my website I uses virtual subdomains.
In my .htaccess I have the following rules:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.site\.com?$
RewriteCond %{HTTP_HOST} ^([^.]+)\.site\.com?$
RewriteRule ^$ /subdomain.php?subdomain=%1 [L]

It should works like this:
http: // subdomain.site.com display the content of subdomain.php

This is OK!

http:// WWW .subdomain.site.com/ display the content of the http:// www .site.com WHICH is wrong. I want all www. subdomain.site.com be redirected to www. site.com

If I type http :// subdomain.site.com/category/name_of_category I am redirected to http: // WWW .subdomain.site.com/category/name_of_category and it is diaplyed the content of http: // www. site.com/category/name_of_category
Instead of that I need a 404 error response.
How can I resolve this problem ?

Thank you very much!



 10:41 pm on Oct 17, 2013 (gmt 0)



Host can be exactly www.example.com OR exactly www.example.co. Maybe, but I strongly suspect you mean


<further tangent>
Find and read the boilerplate on using "example.com". There are many reasons for it. But auto-linking only kicks in when there's a preceding http://
</further tangent>

http://WWW.subdomain.example.com/ display the content of the http://www.example.com WHICH is wrong. I want all www.subdomain.example.com be redirected to www.site.com

Where is the code that says so?

If I type http://subdomain.example.com/category/name_of_category I am redirected to http://WWW.subdomain.example.com/category/name_of_category

Then there must be additional RewriteRules involved, because-- independent of any hostname issues-- the quoted rule only applies to requests for the root ^$ From the information given, it's impossible to tell whether we're dealing with the results of other rules in the same htaccess, or rules at the host/config level.

By the way, I hope that wasn't a verbatim quote from htaccess, since it would imply that the subdomain rewrite is the very first RewriteRule. It should be one of the last, after any explicit redirects are out of the way.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved