1

i having problem with .htacess redirect URL's to sub-folders (sub-directory). My Folder Structure was like. i had two directories in my root folder web and sales.

Root

Directory 1 - web/4.5 , Directory 2 - sales/2.5

And my main URL site was like http ://beta.example.com

when user hits the root URL (http ://beta.example.com) it should redirect to sub-folder name web/4.5 for this i wrote code and it was working.the code was like.

RewriteEngine On

RewriteCond %{HTTP_HOST} ^beta.example\.com$
RewriteCond %{REQUEST_URI} !^/web/4.5
RewriteRule (.*) /web/4.5/$1

the above code was working but, when user hits the root URL (http ://beta.example.com/sales/) it should redirect to sub-folder sales/2.5 for this i wrote code and it was not working.the code was like.

RewriteEngine On

RewriteRule ^sales/(.*) sales/2.5/$1

RewriteCond %{HTTP_HOST} ^beta.example\.com$
RewriteCond %{REQUEST_URI} !^/web/4.5
RewriteRule (.*) /web/4.5/$1

it was not working ,it goes to web/4.5/sales/2.5/ ,actually it goes to /sales/2.5/

    -

senthilbp
  • 807
  • 1
  • 9
  • 16
charan
  • 53
  • 4

1 Answers1

0

Here

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/sales/2.5
RewriteRule ^sales/(.*) /sales/2.5/$1 [L]

RewriteCond %{REQUEST_URI} !^/sales/2.5
RewriteCond %{REQUEST_URI} !^/web/4.5
RewriteRule (.*) /web/4.5/$1

The [L] stops following redirect processes.

KNaito
  • 3,930
  • 2
  • 19
  • 21
  • Thanks ,but it was not working it still goes to web/2.5/ , here my problem was when user enter http ://beta.example.com/sales it redirect to sales/2.5/ folder but it goes to web/ folder and after you suggestion i wrote like RewriteEngine On RewriteCond %{HTTP_HOST} ^beta.lytepole\.com$ RewriteCond %{REQUEST_URI} !^/web/4.0 RewriteRule (.*) /web/4.0/$1 RewriteCond %{REQUEST_URI} !^/sales/3.6 RewriteRule ^/sales/(.*) /sales/3.6/$1 [L] – charan Apr 17 '14 at 07:01
  • Sorry, now I modified my answer. I check ^/sales/2.5 in each ReriteRule. – KNaito Apr 17 '14 at 07:13