Somenath Sinha Somenath Sinha - 1 year ago 56
PHP Question

How to automatically eliminate the file name from the url?

I'm already using RewriteEngine and RewriteConditions to eliminate the .php part from the file name.

However, I visited this site recently,
. In it, just to mess around, I tried finding the actual file name, which turned out to be index.php. However, when I tried to go to
, the site automatically shortens the url to
. How is this behavior achieved?

Also, am I correct in assuming that the page's original address ends in index.php? Or is the site simply redirecting me? How do I recreate this in my own websites?

Answer Source

Since you have not provided your original .htaccess code this is the best i can do.

RewriteCond %{THE_REQUEST} ^.*/index\.php 
RewriteRule ^(.*)index.php$ /$1 [R=301,L] 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download