0

我已经在这个问题上工作了几个晚上,但没有运气。我正在尝试使用 (.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]
4

2 回答 2

0

您不能匹配带有 %{HTTP_HOST} 变量的 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]
于 2012-08-24T19:00:43.670 回答
0

要在 URI 中使用 a重写请求UserDir,您必须设置 a RewriteBase

RewriteBase /~mpnl/
于 2016-05-30T17:22:10.933 回答