2

我使用这个 .htaccess 将我的论坛从子域重定向到 /forum/ 文件夹

#REDIRECT FORUM
RewriteCond %{HTTP_HOST} ^forum\.example\.com$
RewriteRule ^ http://www.example.com/forum/%{REQUEST_URI} [R=301,L]

一切都很好,但我的请求得到了意想不到的结果:

http://forum.example.com/forum/10  =>  http://www.example.com/forum/10

不得不

http://forum.example.com/forum/10  =>  http://www.example.com/forum/forum/10

哪里有错?

4

2 回答 2

1

尝试这个:

#REDIRECT FORUM
RewriteCond %{HTTP_HOST} ^forum\.example\.com$
RewriteRule ^/(.*) http://www.example.com/forum/forum/$1 [R=301,L]
于 2013-02-13T23:54:34.503 回答
0

您的 .htaccess 几乎没有错误。我将您的 .htaccess 的更正版本放在这里:

# OPTIONS
DirectoryIndex index.php index.htm index.html
AddDefaultCharset utf-8

RewriteEngine On
RewriteBase /

# REDIRECT FORUM
RewriteCond %{HTTP_HOST} ^forum\.sathyasai\.ru$ [NC]
RewriteRule ^ http://www.sathyasai.ru/forum%{REQUEST_URI} [R=301,L]

# RUN OLD_SITE
RewriteCond %{REQUEST_URI} !^/v2
RewriteCond %{DOCUMENT_ROOT}/v2%{REQUEST_URI} -f
RewriteRule (.*) /v2/$1 [L]

# RUN NEW_SITE
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.php [L]
于 2013-02-14T10:49:13.487 回答