Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other .htaccess rewrite url Re: .htaccess rewrite url

#140367
__
Participant

>All i want is the address bar to show the http://example.com/index so people can’t see the file type ;-)

…then all you need to do is write your links like

link!

and not like

link!

and use the .htaccess snippet @ChrisBurton link to. “`example.com/pretty`” is what the user will see in their address bar when they click on it; “`example.com/pretty.php`” is the page Apache will serve.

*****
>When i type in what AWKM said it shows page error :/

right – as I said, it’s a touchy/inefficient “solution” to a problem that doesn’t exist. This is nothing against @AWKM; it’s just not a good idea in the first place.

(also, it shouldn’t be all on one line like that: it should look like this in your `.htaccess` file:

RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} ^GET (.).php HTTP
RewriteRule (.).php$ $1 [R=301]
RewriteRule (.)/index$ $1/ [R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.)/ $1 [R=301]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1.php [L]