Hi, I am a newbie..plzz help me out in this. The scenario is like this: There is a folder on the root named as "application". Inside this folder there are subfolders containing index.php files. So, when we tried to access the subfolders containing index.php files , the url on the address bar will be www.somewebsite.com/application/folder1/index.php Now, we dont want "application" to be displayed in the url. To fulfill the above requirement, In .htaccess we added a code snippet : RewriteEngine On RewriteCond %{REQUEST_URI} !^/application/.*$ RewriteRule ^folder1/(.*)$ /application/folder1/$1 This successfully solves the problem by making the url access the page in both ways URL1 : www.somewebsite.com/application/folder1/index.php URL2 : www.somewebsite.com/folder1/index.php But , now the problem is : I want to do 301 redirect whenever URL1 is clicked , it should redirect to URL2. How to achieve this in .htaccess ? can you provide me with some generic code.. Any help is appreciated...
Hi, This is the correct .htaccess code for 301 redirection RewriteEngine On RewriteCond %{REQUEST_URI} !^/application/.*$ RewriteRule ^folder1/(.*)$ /application/folder1/$1 [R=301,L]
Thank you nikhilrajr, The above codespec when added to htaccess it redirects me from www.somewebsite.com/folder1/index.php to www.somewebsite.com/application/folder1/index.php. I want it to redirect in a reverse way. Plz have a look on the above scenario for better understanding.
Try this RewriteEngine On RewriteCond %{REQUEST_URI} ^/application/.*$ RewriteRule ^folder1/(.*)$ /application/folder1/$1 [R=301,L]