RewriteRule help please

Discussion in 'Apache' started by nikolaaa, Apr 15, 2007.

  1. #1
    I want to dynamically make subdomain.

    My .htaccess:

    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} !^www\.mysite\.net
    RewriteCond %{HTTP_HOST} ([^.]+)\.mysite\.net [NC]
    RewriteRule ^(.*)$ http://www.mysite/content.php?key=%1 [L,R]
    
    Code (markup):

    I want when user come on something.mysite.net to stay in that subdomain and page genarate from http://www.mysite/content.php?key=something

    It works fine but when you come on something.mysite.net it redirect you to
    http://www.mysite/content.php?key=something

    How to stop redirection?
     
    nikolaaa, Apr 15, 2007 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Remove the R (redirect) flag and change the absolute URL to a relative path.

    For example, if the htaccess file is at mysite.net/.htaccess
    RewriteRule ^(.*)$ content.php?key=%1 [L]
    Code (markup):
    You will probably also need to specify the rewritebase as the root of your domain. Add this line after RewriteEngine On:
    RewriteBase /
    Code (markup):
     
    rodney88, Apr 15, 2007 IP