How to rewrite a folder name in URL using htaccess

I want to rewrite a folder name(administrator) to (admin) in the URL using .htaccess.


For eg;

My actual url:

        http://localhost/administrator/index.php

it should be rewritten as

         http://localhost/admin/index.php


So end user should not aware about my administrator folder.
he should call the administrator side using admin folder.




kumarjcetAsked:
Who is Participating?
 
torakeshbConnect With a Mentor Commented:
0
 
sweetfa2Commented:
RewriteEngine on
^/administrator(.*) /admin$1

Open in new window

0
 
StingRaYCommented:
RewriteEngine on
RewriteBase /
^/administrator/(.*) /admin/$1

Open in new window

0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
StingRaYCommented:
RewriteEngine on
RewriteBase /
RewriteRule ^/administrator/(.*) /admin/$1
RewriteRule ^/administrator$ /admin

Open in new window

0
 
kumarjcetAuthor Commented:
I have used this one


RewriteRule ^admin/(.*) administrator/$1


this is working

http://localhost/admin/index.php ...



Now the issue is

while redirecting to  http://localhost/administrator/test.php  

it should automatically rewrite as  http://localhost/admin/test.php

but i am getting only  http://localhost/administrator/test.php  


Any help on this...




0
 
StingRaYCommented:
RewriteEngine on
RewriteBase /
RewriteRule ^/admin/(.*) /administrator/$1
RewriteRule ^/admin$ /administrator

Open in new window

0
 
StingRaYCommented:
By my latest reply, when user access http://localhost/admin/test.php, he will be redirected to http://localhost/administrator/test.php.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.