I'm while using Kohana framework (however i think it's irrelevant with this question) and pages could be utilized like so


Now, usually of thumb, I generally try to tweak my .htaccess to simply allow one means by for any page, and quietly redirect other common ways.

Basically, within the first URL above, the address is really internally rerouted towards the second example.

What I wish to do, would be to pressure any Web addresses from the second type in becoming Web addresses from the first type. I am not frequently positive about .htaccess, and my first attempt is tossing some unpredicted results (like endless loops occasionally)

Here's what I have emerged with

RewriteRule ^index\.php/(.*) $1 [NC,L,R=301]

Can anybody let me know what I am doing wrong, and when you've also went into this issue, how perhaps you have solved it?


I have made the decision to publish my entire .htaccess so that all of my redirects could be examined.

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /~toberua/

# file not found page
    ErrorDocument 404 /404/
    ErrorDocument 403 /403/

# get people out of my directories
    Options -Indexes

# default page to load
    DirectoryIndex index.php

# add trailing slash if missing
    RewriteRule ^(([a-z0-9\-]+/)*[a-z0-9\-]+)$ $1/ [NC,R=301,L]

# redirect /favicon.ico requests
     RewriteCond %{REQUEST_URI} !^/images/layout/favicon\.ico [NC]
     RewriteCond %{REQUEST_URI} favicon\.(gif|ico|png|jpe?g) [NC]
     RewriteRule (.*) images/layout/favicon.ico [R=301,L]

# send /home back to TLD
     RewriteRule home/ $1  [NC,R=301,L]

# ensure there is no /index.php in the address bar
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
    RewriteRule ^(.*)index\.php$ $1 [R=301,L] # this was my attempt to stop /dir/index.php and make it simply /dir/

    RewriteRule ^index\.php/(.*) $1 [NS,NC,L,R=301]

# Protect application and system files from being viewed
RewriteRule ^(application|modules|system) - [F,L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]

Do this:

RewriteRule ^index\.php/(.*) $1 [NS,NC,L,R=301]

What you are not processing is the fact that all demands are susceptible to spinning, so when you perform a rewrite it generate a subrequest -- also is susceptible to spinning. Which means you find yourself spinning /articles to /index.php/articles, then within the subrequest that that problem, you rewrite /index.php/articles to /articles and generate a brand new request the 301 redirect, so on. Adding the NS flag can make this rule not work on subrequests, that we think should fix your condition, unless of course you are also carrying out a 301 around the /articles -> /index.php/articles rewrite (but that might be madness).