Welcome to WebmasterWorld Guest from 54.163.39.19

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

htaccess and dynamic subdomains

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

New User

joined:May 3, 2013
posts: 3
votes: 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
10:09 am on May 20, 2013 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11133
votes: 115


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.
10:49 am on May 20, 2013 (gmt 0)

New User

joined:May 3, 2013
posts:3
votes: 0


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

Cheers
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members