(.htaccess)如何将一个代字号用户站点mod_rewrite到同一站点内的子文件夹

时间:2012-08-24 16:50:43

标签: apache .htaccess redirect subdirectory tilde

我一直在这个问题上工作几个晚上没有运气。我正在尝试使用(.htaccess)重写Web请求 来自:cobweb.seas.gwu.edu/~mpnl 致:cobweb.seas.gwu.edu/~mpnl/joomla

我的最新(.htaccess)文件如下:

# turn on Rewrite
RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www.)?cobweb.seas.gwu.edu/~mpnl$
RewriteCond %{REQUEST_URI} !^/joomla/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /joomla/$1 [L]

RewriteRule ^(/)?$ joomla/index.php [L]

2 个答案:

答案 0 :(得分:0)

您无法与%{HTTP_HOST} var匹配URI路径,只能与主机匹配。您需要将~mpnl部分包含为重写基础或作为请求URI的一部分:

RewriteEngine on

# remove the "/~mpnl" from the end of this line, add a [NC]
RewriteCond %{HTTP_HOST} ^(www.)?cobweb.seas.gwu.edu$ [NC]
# add a "/~mpnl" to here
RewriteCond %{REQUEST_URI} !^/~mpnl/joomla/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# remove the leading slash before "joomla"
RewriteRule ^(.*)$ joomla/$1 [L]

# add a condition to this:
RewriteCond %{REQUEST_URI} !^/~mpnl/joomla/
RewriteRule ^(/)?$ joomla/index.php [L]

答案 1 :(得分:0)

要在URI中rewriteUserDir次请求,您必须设置RewriteBase

Excel.run(function (ctx) {

}