homepage Welcome to WebmasterWorld Guest from 54.198.9.77
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
htaccess and dynamic subdomains
4theuk




msg:4575665
 8:28 am on May 20, 2013 (gmt 0)

Hi,

Please can you help me. I am trying to set up a domain that uses dynamic subdomains to show content instead of a folder eg.

field1.example.com/field2/index.html

The pages are created in php with the two fields and

example.com?index.php?field1=XXX&field2=YYY works fine

However using the following htaccess rule

RewriteRule ^(.*)$.example.com/.*)/index.html$ index.php?field1=$1&field2=$2 [NC]

shows a 404 error.

wild card subdomains have been enabled on the domain.

Thanks

 

phranque




msg:4575689
 10:09 am on May 20, 2013 (gmt 0)

welcome to WebmasterWorld, 4theuk!


RewriteRule ^(.*)$.example.com/.*)/index.html$ index.php?field1=$1&field2=$2 [NC]


the RewriteRule Pattern matches the path which does not include the hostname.

if you want to capture and use part of the hostname in your RewriteRule you must use a RewriteCond backreference (%N) and specify the HTTP_HOST server variable as the TestString in the RewriteCond.

4theuk




msg:4575712
 10:49 am on May 20, 2013 (gmt 0)

Thank you phranque for your explanation as to why it wouldn't work.

Cheers

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.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved