Reputation: 15002
I am currently trying to clean URL in my local machine(wamp) before using that(.htaccess) script in my online website. This is my localhost address
http://localhost/index.php
http://localhost/people.php
http://localhost/current.php
i want to clean this url to
http://localhost/home/
http://localhost/People/
http://localhost/Current/
respectively. But for start(and also for easy) i want to change only index.php file to home . i found this script while searching web
RewriteEngine on
RewriteRule ^home/?$ index.php [NC,L]
but when i tried this script in my local machine nothing worked,still my url is showing like this
http://localhost/index.php
i dont know where i went wrong, can any one help me..
Upvotes: 0
Views: 1977
Reputation: 175028
You probably have some sort of misconception over how rewriting works:
RewriteEngine on
RewriteRule ^home/?$ index.php [NC,L]
This means that if the URL (which was typed in the browser) matches the first argument (^home/?$
), that request should be rewritten to index.php
.
What you should do, is instead of trying to get to type index.php
in the browser bar, type http://localhost/home/
. You should see the index page, even though the browser address bar says /home/
.
Upvotes: 1
Reputation: 345
Open up .htaccess and insert the following code:
RewriteEngine On
Options -multiviews
RewriteRule ^home/$ index.php [L]
RewriteRule ^People/$ people.php [L]
RewriteRule ^Current/$ current.php [L]
Then go to your website URL and do: /home/ (and /People/ /Current/)
Upvotes: 1