logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: how to host multiple sites, each with rewriterule's
Author
ssmith



Joined: 26 Feb 2011
Posts: 1

PostPosted: Sat 26 Feb '11 8:06    Post subject: how to host multiple sites, each with rewriterule's Reply with quote

I have apache 2.2 and 3 local sites
c:\apache2.2\htdocs\mymainsite\
c:\apache2.2\htdocs\mymainsite\subsite1\
c:\apache2.2\htdocs\mymainsite\subsite2\

mymainsite will show just a directory listing of the other subsites.
None are live yet, so it is all local hosting.
So I read apache documents and tried the following with no success yet.
Is it correct approach?


1. I add this to httpd-vhosts.conf
######################
# my main site
<VirtualHost *:80>
RewriteEngine On
RewriteOptions Inherit
<Directory "C:/Apache2.2/htdocs/mymainsite">
RewriteBase /mymainsite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
</Directory>

ServerName mymainsite.loc
DocumentRoot "C:/Apache2.2/htdocs/mymainsite"
</VirtualHost>

# subsite 1
<VirtualHost *:80>
RewriteEngine On
RewriteOptions Inherit

<Directory "C:/Apache2.2/htdocs/mymainsite/subsite1">
RewriteBase /mymainsite/subsite1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
</Directory>

ServerName subsite1.loc
DocumentRoot "C:/Apache2.2/htdocs/mymainsite/subsite1"
</VirtualHost>
etc.

and

2. I include in httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
Include conf/extra/httpd-vhosts.conf
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
<Directory "C:/Apache2.2/htdocs">
AllowOverride none
</Directory>
NameVirtualHost mymainsite.loc
NameVirtualHost subsite1.loc
NameVirtualHost subsite2.loc


and

3. I edit windows hosts file like:
###################
127.0.0.1 localhost
::1 localhost
127.0.0.1 mymainsite.loc
127.0.0.1 subsite1.loc
127.0.0.1 subsite2.loc


Is this the correct?
Should Directory be inside VirtualHost?
I want to be able to enter a url like
http://mymainsite.loc\aaa\bbb\ccc
and
http://subsite1.loc/aaa/bbb/ccc
where folders aaa/bbb/ccc don't exist but the rewrite rule sends the url to correct index.php, and then decides what page to present.
Thanks
Smith
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7407
Location: EU, Germany, Next to Hamburg

PostPosted: Wed 16 Mar '11 2:07    Post subject: Reply with quote

Why are you using rewrite instead of several vhosts?
Back to top


Reply to topic   Topic: how to host multiple sites, each with rewriterule's View previous topic :: View next topic
Post new topic   Forum Index -> Apache