'How to hide url in Address bar
I want to keep same url for all the pages of my site.
ex: if my site is www.abc.com & xyz.html is a page.
I want to display www.abc.com or www.abc.com/xyz instead of www.abc.com/xyz.htm
Please help me to do this.
Thank you in advance.
Solution 1:[1]
use .htaccess see link to know how to use it (focus on rewrite rule): http://httpd.apache.org/docs/current/howto/htaccess.html
Solution 2:[2]
You can use javascript for that , for example
<script>
var stateObj = { foo: "bar" };
history.pushState(stateObj, "page without extension", "xyz");
</script>
You can read more about here :
Or use a PHP Routing system, theres a lot of information about it in google
Solution 3:[3]
Use this snippets in your .htaccess file
Now you can use this in Url abc.com/xyz and it redirect you to abc.com/xyz.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9] {1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Pepo_rasta |
| Solution 2 | Community |
| Solution 3 | Hasibul Hasn |
