0

我有:

public/
-- index.php
-- my_subdir/
---- index.php

我只是想重新路由到 my_subdir。

(为什么?因为 my_subdir 包含我的新 joomla 网站。)

编辑,解释为什么所有其他解决方案都不起作用......我已经为此工作了几个小时,但没有任何效果。即使这里接受的答案最初也不起作用。问题不是谷歌提供的许多解决方案,而是我有冲突的规则/条件。

所以这是一个我没有工作的例子(箭头右边的东西是我需要让一切正常工作的东西):

RewriteEngine on

<<<< RewriteCond %{REMOTE_HOST} !^111\.111\.111\.111 
######## my ip address for testing 
########   because this was not originally included, 
########     apparently I was being redirected to maintenance.html ...
RewriteCond %{REQUEST_URI} !/maintenance.html$ 
RewriteRule $ /maintenance.html [R=302]

######## thus by the time the script/server got to this line
########   I was actually at maintenance.html,
########     and so this next condition did not apply to me
RewriteCond %{REQUEST_URI} !^/my_subdir
RewriteRule ^.*$ /my_subdir/$0 [L]
4

1 回答 1

1

如果您有下面相同的目录结构my_subdir,您可以简单地重写所有内容

RewriteCond %{REQUEST_URI} !^/my_subdir
RewriteRule ^.*$ /my_subdir/$0 [L]

如果您想重定向,即使新 URL 在浏览器中可见,您还必须添加R标志

RewriteRule ^.*$ /my_subdir/$0 [R,L]
于 2013-04-15T14:54:07.880 回答