Forum Moderators: phranque
I have a new website in development whose URLs are like:
www.example.com/index.php/page/file-name
Now I would like to strip the "/index.php/page" part from the URL so that the URL becomes
www.example.com/file-name
Also there are some that have URLs like
www.example.com/index.php/file-name
From which I would like to remove the /index.php part as well.
Kindly advise, thanks!
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.
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.