Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hide .php from address bar

I use php to build web applications, but i want my web pages without .php extension in the browser's address bar. For eample http://www.example.com/index.php shows like http://www.example.com/index in the browser's address bar.

How can i do this?

like image 554
World Avatar asked Apr 29 '11 11:04

World


People also ask

Can I hide URL in address bar?

No you can't. Imagine spoofing https://yourbank.com/ instead of http://fakesite.com/ . The only way to see a different URL is to proxy the response, or putting it in a frame. The only way to "hide" your URL would be to use frames.

Is PHP code hidden?

However, if the website contains PHP code, that code is not visible, because all the PHP code is executed on the server before the website is sent to a browser. All the browser ever receives is the result of the PHP embedded in the HTML.

How do I hide a URL in Chrome?

To hide the bar, all you can do is use Chrome's full-screen mode. To enter full-screen mode, press F11 or click Chrome's menu button and click the “Full Screen” icon to the right of the Zoom options.


1 Answers

Put this in a file named .htaccess in your WWW-root:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(([A-Za-z0-9\-]+/)*[A-Za-z0-9\-]+)?$ $1.php

This works if you're running Apache and have mod_rewrite activated.

like image 101
Karl Laurentius Roos Avatar answered Sep 24 '22 23:09

Karl Laurentius Roos