homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Remove /index.php/page from URLs

 11:38 am on Nov 2, 2009 (gmt 0)


I have a new website in development whose URLs are like:


Now I would like to strip the "/index.php/page" part from the URL so that the URL becomes


Also there are some that have URLs like


From which I would like to remove the /index.php part as well.

Kindly advise, thanks!



 9:29 pm on Nov 2, 2009 (gmt 0)

Link to the new URLs from the pages of the site.

Set up a rewrite to accept those incoming URL requests and fetch the correct internal path for the content.

Set up an external redirect such that requests for the unwanted URL format are redirected to make a new request for the correct URL.

There's many similar examples in prior threads. Post your best effort code as a basis for discussion.


 10:48 am on Nov 3, 2009 (gmt 0)

Ok...it was built using CodeIgniter and this code helped fix it:

RewriteEngine on
RewriteCond $1 !^(index\.php¦images¦robots\.txt)
RewriteRule ^(.*)$ /index.php/page/$1 [L]

Working on the redirects now...

Thanks again!


 11:08 am on Nov 3, 2009 (gmt 0)

The redirects are going to be quite a bit trickier, because you are probably going to need to detect an external request and Redirect it, then Rewrite internal requests to index.php so you can serve the information, and unfortunately there are lots of examples here, but this is one of those 'very specific' situations... The following should give you a specific starting point, but you are going to need to work on the Rewrite to serve the information.

I highly recommend testing all code on a test site or in a test directory before trying this live. What I post below should Redirect as you are asking, but it will NOT rewrite so you can serve the information. IOW: This is only a portion of the code you need, and I'll leave it to you (and others) to figure out (or explain) what it does and how to incorporate it with the rest of what you need.

RewriteEngine on

RewriteRule %{THE_REQUEST} ^[A-Z]{2,6}\ /index.php
RewriteRule ^index\.php/(page/)?([^.]+)$ http://www.example.com/$2 [R=301,L]

NOTE: Check out the library, links at the top left of the forum pages, specifically, jdMorgan's post about making URLs 'search engine friendly', because it will probably describe what you need to do and what this does most accurately, even if it's not the 'specific solution' to your problem.


 7:06 pm on Nov 3, 2009 (gmt 0)

Thanks a lot MadScientist.

We are trying all this on our test server and not on the live site. I will try this code and post feedback here.

Thanks again!


 12:18 am on Nov 4, 2009 (gmt 0)

We are trying all this on our test server.

If only everyone did this. Sigh!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved