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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With