Stefany93 Posted December 8, 2013 Share Posted December 8, 2013 Howdy, I have a directory named directory1 and the user can access it by typing www.example.com/directory1. However, I want to make it so that the user would type www.example.com/directory2 but they will land on wwww.example.com/directory1, but the URL will show www.example.com/directory2 I tried doing that with this .htaccess: RewriteRule /directory2/ /directory1/ but it didn't work. I also searched in google but in vain. Please help! Quote Link to comment https://forums.phpfreaks.com/topic/284624-rewriting-directory-name-with-htaccess/ Share on other sites More sharing options...
therocker Posted December 9, 2013 Share Posted December 9, 2013 (edited) RewriteRule ^/directory2/$ /directory1/ Edited December 9, 2013 by therocker Quote Link to comment https://forums.phpfreaks.com/topic/284624-rewriting-directory-name-with-htaccess/#findComment-1461738 Share on other sites More sharing options...
Stefany93 Posted December 9, 2013 Author Share Posted December 9, 2013 Still does not work, here is the code. Thank you for you reply tho RewriteEngine On RewriteRule ^/directory2/$ /directory1/ Quote Link to comment https://forums.phpfreaks.com/topic/284624-rewriting-directory-name-with-htaccess/#findComment-1461867 Share on other sites More sharing options...
Ch0cu3r Posted December 9, 2013 Share Posted December 9, 2013 You need to also pass on the file request too RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^/directory2/(.*)$ /directory1/$1 Quote Link to comment https://forums.phpfreaks.com/topic/284624-rewriting-directory-name-with-htaccess/#findComment-1461877 Share on other sites More sharing options...
jazzman1 Posted December 10, 2013 Share Posted December 10, 2013 I tried doing that with this .htaccess: RewriteRule /directory2/ /directory1/ It is correct. Check out whether you have directories with these names in apache web root folder. Quote Link to comment https://forums.phpfreaks.com/topic/284624-rewriting-directory-name-with-htaccess/#findComment-1461895 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.