Mod_rewrite

This is a discussion on Mod_rewrite within the Apache Web Server forums, part of the Web Server and Related Forums category; Hi, I am currently running Apache 1.3.27 with Debian Woody and I am looking to setup an easy ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-12-2004
Matthew Bates
 
Posts: n/a
Default Mod_rewrite

Hi,

I am currently running Apache 1.3.27 with Debian Woody and I am looking to
setup an easy virtual host solution. I am using mod_vhost_alias at the
moment but I would prefer to use mod_rewrite as it offers more flexibility.
However I am having problems and I would appreciate anybody's thoughts and
ideas.

I currently have (based on the code from the Apache docs):
----------
RewriteEngine on

RewriteMap lowercase int:tolower

RewriteMap vhost txt:/xxx/xxxxx/vhost.map

RewriteCond %{REQUEST_URI} !^/icons/
RewriteCond %{REQUEST_URI} !^/cgi-bin/
RewriteCond %{REQUEST_URI} !^/webmail/

RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/public_html/$1

RewriteCond %{REQUEST_URI} ^/cgi-bin/
RewriteCond %{HTTP_HOST} !^$
RewriteCond ${lowercase:%{HTTP_HOST}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/cgi-bin/$1
----------

The virtual hosts are litsted in vhost.map as:
----------
domain.com /home/website1
----------

The rewrite works when the domain is referenced as "domain.com" however
www.domain.com produces a 404 (points to /usr/htdocs).

My question is, how can I take into account the www?

Also, I have been considering upgrading to Apache 2.0.48 which I now believe
is recommended for production. However what is the status of the
interoperability with PHP? I have read on the PHP site that it is not
recommended to run Apache 2.0 with PHP but does this refer to the latest
revisions or the initial release?

Many thanks in advance,

MB


  #2 (permalink)  
Old 01-18-2004
Rossz
 
Posts: n/a
Default Re: Mod_rewrite

Matthew Bates wrote:

> The rewrite works when the domain is referenced as "domain.com" however
> www.domain.com produces a 404 (points to /usr/htdocs).
>
> My question is, how can I take into account the www?


The simplist way would be to remove the www. at the very start. This is
untested:

RewriteRule www\.(.*) $1

Alternately, add a duplicate entry but with the www. in your vhost mapping.

> Also, I have been considering upgrading to Apache 2.0.48 which I now believe
> is recommended for production. However what is the status of the
> interoperability with PHP? I have read on the PHP site that it is not
> recommended to run Apache 2.0 with PHP but does this refer to the latest
> revisions or the initial release?


I don't recommend upgrading to 2.x. There are a lot of modules that
have not been ported to the 2.x branch at this time.

--
Rossz
  #3 (permalink)  
Old 01-18-2004
Matthew Bates
 
Posts: n/a
Default Re: Mod_rewrite

Thanks for your reply.

I now have the following, however it is not working. I would be grateful if
someone could explain the process (e.g. rules/conditions) and what may be
wrong here?

---------
RewriteEngine on

RewriteMap lowercase int:tolower

RewriteMap vhost txt:/xxx/xxxxx/vhost.map

RewriteCond %{REQUEST_URI} !^/icons/
RewriteCond %{REQUEST_URI} !^/cgi-bin/
RewriteCond %{REQUEST_URI} !^/webmail/

RewriteRule www\.(.*) $1

RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/public_html/$1

RewriteCond %{REQUEST_URI} ^/cgi-bin/
RewriteCond %{HTTP_HOST} !^$
RewriteCond ${lowercase:%{HTTP_HOST}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/cgi-bin/$1
---------

Thanks,
Matthew

"Rossz" <rosszNOSPAM@vamos-wentworth.org> wrote in message
news:nvtOb.12757$W%3.6130@newssvr27.news.prodigy.c om...
> Matthew Bates wrote:
>
> > The rewrite works when the domain is referenced as "domain.com" however
> > www.domain.com produces a 404 (points to /usr/htdocs).
> >
> > My question is, how can I take into account the www?

>
> The simplist way would be to remove the www. at the very start. This is
> untested:
>
> RewriteRule www\.(.*) $1
>
> Alternately, add a duplicate entry but with the www. in your vhost

mapping.
>
> > Also, I have been considering upgrading to Apache 2.0.48 which I now

believe
> > is recommended for production. However what is the status of the
> > interoperability with PHP? I have read on the PHP site that it is not
> > recommended to run Apache 2.0 with PHP but does this refer to the latest
> > revisions or the initial release?

>
> I don't recommend upgrading to 2.x. There are a lot of modules that
> have not been ported to the 2.x branch at this time.
>
> --
> Rossz



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:33 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0