You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by thomas Armstrong <ta...@gmail.com> on 2008/02/04 23:20:33 UTC

[users@httpd] RewriteRule: foo.com/directory --> foo.com/directory/

Hi.

Using Apache 2, I want to create a RewriteRule within the '.htaccess'
file which redirects from:
http://foo.com/directory
to
http://foo.com/directory/

This last "directory" is a RewriteRule:
----------
RewriteRule ^([^/]+)/$ /directory.php?label=$1 [L]
---------

I tried adding this line
---------
RewriteRule ^(.*)$ /$1/ [R=301]
---------
after and before the last line, but I get this error message:
------
The page isn't redirecting properly
------

and the URL I get is:
http://foo.com/directory.php/?label=directory.php

What am I doing wrong? Thank you very much.

---------------------------------------------------------------------
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] RewriteRule: foo.com/directory --> foo.com/directory/

Posted by Eric Covener <co...@gmail.com>.
On Feb 4, 2008 5:20 PM, thomas Armstrong <ta...@gmail.com> wrote:
> I tried adding this line
> ---------
> RewriteRule ^(.*)$ /$1/ [R=301]
> ---------

> The page isn't redirecting properly

At least protect it from running when the URL ends in a slash such as:

RewriteRule ^(.*[^/])$ /$1/ [R=301]

You're unexpected behavior is a result of doing rewrite in .htaccess,
so the rules are re-visited at a later stage despite the L flag.
-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
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