Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthoraconnor
    • CommentTimeJan 14th 2008
     permalink
    I have the following rewrite rules:

    RewriteRule ^([a-zA-Z0-9_-]+)\.php$ $1/ [R,NC]
    RewriteRule ^([a-zA-Z0-9_-]+)/$ $1\.php [NC,L]

    which seem to be resolving into an infinite loop. My question is why? Shouldn't the "L" flag in the second rule end the rule processing?

    Thanks in advance for the help.

    -adam
    • CommentAuthorPettyRider
    • CommentTimeJan 15th 2008
     permalink
    Your rules are essentially complete opposites.

    "file.php > file > file.php > file > file.php > file > ..."

    So, what exactly are you trying to achieve here?
    • CommentAuthorvarland
    • CommentTimeJan 16th 2008
     permalink
    He's trying to not show file extensions. If somebody requests "/index.php", the first rule redirects them to "/index/". Then, the second rule points "/index/" to "/index.php". The key is that the first rule actually redirects.
  1.  permalink
    This doesn't do exactly what you want, but should only require a small amount of work. The basic principle is matching the redirect rule against the original request header to avoid the inifite loop. This example redirects all requests for ...something/index.php to ..something/.

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
    RewriteRule ^(.*)index\.php$ http://%{HTTP_HOST}/$1 [R=301,L]
Add your comments
    Username Password
  • Format comments as (Help)