mod rewrite - Apache httpd.conf - Link multiple domains to corresponding subfolders -


i need rule internally rewrite several domains, , without www:

www.a.com --> /m/n/o/ b.c.org --> /x/y/z/ 

the setup apache running locally on windows (xampp). i've got hosts file set domains point localhost. i'd every page redirected, i.e. want point each domain it's own different root directory , have work there. e.g.

/                          <-- top level folder, under here.    /root/of/domain/a/      <-- www.a.com    /root/of/domain/c/      <-- b.c.org 

you have 2 choices.

(1) 1 asked (with mod_rewrite)

<ifmodule mod_rewrite.c>   rewriteengine on    rewritecond %{http_host} ^(?:www\.)?a\.com$ [nc]   rewriterule ^/(.*)$ /root/of/domain/a/$1 [l]    rewritecond %{http_host} ^b\.c\.org$ [nc]   rewriterule ^/(.*)$ /root/of/domain/c/$1 [l] </ifmodule> 

note: don't forget replace example values real ones. also, make sure mod_rewrite enabled.

(2) cleanest way: configure virtualhosts directly (without mod_rewrite)

namevirtualhost *:80  <virtualhost *:80>   documentroot "x:/path/to/root/of/domain/a/"   servername a.com   serveralias www.a.com </virtualhost>  <virtualhost *:80>   documentroot "x:/path/to/root/of/domain/c/"   servername b.c.org </virtualhost> 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -