You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Nick Gushlow <ni...@westcoast.co.uk> on 2005/08/19 10:32:43 UTC

[users@httpd] mod_rewrite problem

Hey guys,

I've got a working set of conditions and a rule, but I'm struggling to
add another condition/rule.

The code below is working and turns any request for http://domain/word
into http://domain/index.php?site=$1 

RewriteLog /var/www/epp/logs/epp.rewrite.log
RewriteLogLevel 9
RewriteEngine on
RewriteCond %{REQUEST_URI} !^.*\.php
RewriteCond %{REQUEST_URI} !^.*\.gif
RewriteCond %{REQUEST_URI} !^.*\.jpg
RewriteCond %{REQUEST_URI} !^.*\.htm
RewriteCond %{REQUEST_URI} !^.*\.html
RewriteCond %{REQUEST_URI} !^.*\.css
RewriteCond %{REQUEST_URI} !^.*\.js
RewriteCond %{REQUEST_URI} !^.*\.doc
RewriteCond %{REQUEST_URI} !^.*\.pdf
# Rewrite URL
RewriteRule /([^/]*)$ /index.php?epp=$1         [L]



I want to add a condition so that it skips the word abbey and continues
as normal - eg http://domain/abbey just reads the abbey directory in
htdocs - so I added


RewriteCond %{REQUEST_URI} !^.*abbey(.*)


It seems to partially work, in mozilla it seems to work, but in IE I
just get page cannot be displayed.

Adding the trailing slash makes it work, so I'm guessing that mozilla
has programming to auto try a trailing slash if it gets page not found.

Question is, what is wrong with my condition/rules that apache is not
adding the trailing slash?  -- note this is a virtual server and the
other virtual servers on the same apache all handle the missing trailing
slash so it's definitely something to do with my rewrite rules.

Any help appreciated.

Thanks,

Nick.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_rewrite problem

Posted by Nick Gushlow <ni...@westcoast.co.uk>.
First off thanks for your help, I clicked reply not reply all before so
I wanted to say thanks publicly so I don't look too ungrateful. :-)

On Fri, 2005-08-19 at 10:57 +0200, Krist van Besien wrote:
> > 
> > RewriteCond %{REQUEST_URI} !^.*abbey(.*)
> 
> A better way to "short circuit" is just to add a 
> 
> RewriteRule  .*abbey.*    -   [L]
> 
> before the existing rule. This keeps the URL unchanged.

That rule didn't work for me and stopped the other rule working
correctly.

I need to get my test server back up got it down for other purposes atm,
then I'll get some logs posted to show what happened.

Nick

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_rewrite problem

Posted by Krist van Besien <kr...@gmail.com>.
On 8/19/05, Nick Gushlow <ni...@westcoast.co.uk> wrote:
> Hey guys,
> 
> I've got a working set of conditions and a rule, but I'm struggling to
> add another condition/rule.
> 
> The code below is working and turns any request for http://domain/word
> into http://domain/index.php?site=$1
> 
> RewriteLog /var/www/epp/logs/epp.rewrite.log
> RewriteLogLevel 9
> RewriteEngine on
> RewriteCond %{REQUEST_URI} !^.*\.php
> RewriteCond %{REQUEST_URI} !^.*\.gif
> RewriteCond %{REQUEST_URI} !^.*\.jpg
> RewriteCond %{REQUEST_URI} !^.*\.htm
> RewriteCond %{REQUEST_URI} !^.*\.html
> RewriteCond %{REQUEST_URI} !^.*\.css
> RewriteCond %{REQUEST_URI} !^.*\.js
> RewriteCond %{REQUEST_URI} !^.*\.doc
> RewriteCond %{REQUEST_URI} !^.*\.pdf
> # Rewrite URL
> RewriteRule /([^/]*)$ /index.php?epp=$1         [L]
> 
> 
> 
> I want to add a condition so that it skips the word abbey and continues
> as normal - eg http://domain/abbey just reads the abbey directory in
> htdocs - so I added
> 
> 
> RewriteCond %{REQUEST_URI} !^.*abbey(.*)

A better way to "short circuit" is just to add a 

RewriteRule  .*abbey.*    -   [L]

before the existing rule. This keeps the URL unchanged.

> It seems to partially work, in mozilla it seems to work, but in IE I
> just get page cannot be displayed.
> 
> Adding the trailing slash makes it work, so I'm guessing that mozilla
> has programming to auto try a trailing slash if it gets page not found.

If your apache is > 2.0.51 what happens when a user requests a URL not
ending in a slash that refers to a directory is that apache sends a
redirect to the correct location, wiith a slash.
(see docs for mod_dir)

> Question is, what is wrong with my condition/rules that apache is not
> adding the trailing slash?  -- note this is a virtual server and the
> other virtual servers on the same apache all handle the missing trailing
> slash so it's definitely something to do with my rewrite rules.

It will probably not be the rewrite rules, as you made them so that
nothing is done to the incoming URL when it contains the word abbey.


Krist

-- 
krist.vanbesien@gmail.com
Solothurn, Switzerland

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org