Reputation: 1
How would I go about shortening down my URLs? At present my URLs are like http://www.server.com/username/aa/index.php/site/products
and I'd prefer the index.php
part not to be there if possible.
Upvotes: 0
Views: 56
Reputation: 525
In general you can a regular expression to fish out the stuff you want to keep and then concatenate it into a replacement. In the snippet bellow ^(.*) (1 or more of any character from the beginning till we hit 'index.php') becomes $1 and eveything after index.php $2
RewriteRule ^(.*)/index\.php/(.*)$ $1/$2[L]
As far as codeingniter and other frameworks go, this should not be necessary at all, you should have something like this in the public directory of your project:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
This willfetch anything going to this directory and redirect to index.php unless a file or directory or link with the explicit name exists
Upvotes: 1