trante
trante

Reputation: 34006

Redirect by htaccess and adding a string

I need two things

  1. Redirect all requests from http://127.0.0.1 to http://127.0.0.1/cakephp
  2. Redirect all requests from http://127.0.0.1/somefolder/someaction to http://127.0.0.1/cakephp/somefolder/someaction
  3. Do nothing if request is to this page http://127.0.0.1/cakephp

I tried this but couldn't make it. Can you recommend the right code?

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1/cakephp/$1 [R]
RewriteCond %{HTTP_HOST} ^127.0.0.1 [NC] 
RewriteRule ^(.*)$ http://127.0.0.1/cakephp/$1 [L,R=301] 

Upvotes: 0

Views: 98

Answers (1)

WebChemist
WebChemist

Reputation: 4411

Try:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^127.0.0.1 [NC] 
RewriteCond %{REQUEST_URI} !^cakephp(/.*)?$
RewriteRule ^(.*)$ /cakephp/$1 [R=301,NC,L] 

Upvotes: 1

Related Questions