0

我需要两件事

  1. 将所有请求从http://127.0.0.1重定向到http://127.0.0.1/cakephp
  2. 将所有请求从http://127.0.0.1/somefolder/someaction重定向到http://127.0.0.1/cakephp/somefolder/someaction
  3. 如果请求到此页面http://127.0.0.1/cakephp ,则不执行任何操作

我试过这个,但做不到。你能推荐正确的代码吗?

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] 
4

1 回答 1

1

尝试:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^127.0.0.1 [NC] 
RewriteCond %{REQUEST_URI} !^cakephp(/.*)?$
RewriteRule ^(.*)$ /cakephp/$1 [R=301,NC,L] 
于 2012-05-09T20:00:29.550 回答