Virtual Subdomains with .htaccess , and rewriting links inside it

Discussion in 'Apache' started by phpjunky, Jul 4, 2013.

  1. #1
    I have successfully created virtual sub-domains using .htaccess
    Now I need to make second url rewriting of these subdomains, for example:
    subdomain.domain.com/index.html will show the content of subdomain.domain.com/index.php but still keeping subdomain.domain.com/index.html in the adress bar.
    in public_html I use inside .htaccess:

    
    RewriteEngine on
    DirectorySlash off
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www\.([^\.]*)\.domain\.com$ [NC]
    RewriteRule (.*) http://%1.domain.com/$1 [R=301,L]
    RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
    RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
    RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com$ [NC]
    RewriteRule ^(.*?)/?$ http://domain.com/users/%1/$1/ [P]
    
    Code (markup):
    but I can't find a working solution to rewrite subdomain.domain.com/index.html >> subdomain.domain.com/index.php
    I tried creating .htaccess inside /users/subdomain/ :

    
    RewriteRule ^index\.html$ index.php [L]
    
    Code (markup):
    But it just does nothing !!
     
    phpjunky, Jul 4, 2013 IP