There was a problem loading the comments.

Point domain to specific directory via rewrites

Support Portal  »  Knowledgebase  »  Viewing Article

  Print
If you have a script installed at /example.com and you want http://example.com/ to show the contents of /example without the address bar changing, you can use the following rewrites to do this:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/example/
RewriteCond %{REQUEST_URI} !^/cgi-bin/awstats.pl
RewriteCond %{HTTP_HOST} ^(www\.)?example_domain
RewriteRule ^(.*)$ example/$1 [L]

Lets break that down.

  • RewriteCond %{REQUEST_URI} !^/example/
    • Example should be the folder that you want to rewrite to.  Not having this causes a loop
  • RewriteCond %{HTTP_HOST} ^(www\.)?example_domain
    • Examplle_domain is your real domain, without the end TLD (.com, .net, .whatever)
    • This isn't needed per say, but if you have multiple domains going to different directories, it helps.
  • RewriteRule ^(.*)$ example/$1 [L]
    • Again, this is the folder that you want to rewrite to. 

Share via

Related Articles

© Cooini, LLC