mod_rewrite virtual hosting question...
alexanderhenry at cox.net
alexanderhenry at cox.net
Wed May 24 16:26:50 MST 2006
---- jon <jon at trafficdesigns.com> wrote:
> I'm totally confused when it comes to mod_rewrite, but here's what I'm
> trying to do -- redirect any instance of a given domain to a specific
> folder.
>
> So.... let's say I want to visit example.com/index.php, the request
> should go to /var/www/sites/example.com/index.php
>
> What I'm looking for is something flexible -- I don't want to have to
> add vhosts everytime we add a domain to the server, just a site.com
> folder in /var/www/sites
>
> Can anyone help... or point the way to good resources?
>
> Thanks....
>
> -- jon
You need to use virtual hosts. mod_rewrite's first argument accepts a path, second argument accepts a path or URL.
<pre>
--------
RewriteEngine on
RewriteRule ^(.*)$ http://www.othersite.com$1
--------
</pre>
This takes a request:
http://example.com/index.php
and parses it, so $1='/index.php'.
Then serves http://www.othersite.com/index.php
Where's the string 'example.com'? Nowhere, the regular expression "^(.*)$" sucked in the whole thing. That's all that is available for mod_rewrite to process.
Now quit trying to be lazy with the 5 minutes it takes to make a new vhost, there's a reason why people get paid for this stuff :)
More information about the PLUG-discuss
mailing list