我使用此.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
哪里出错?
答案 0 :(得分:1)
试试这个:
#REDIRECT FORUM
RewriteCond %{HTTP_HOST} ^forum\.example\.com$
RewriteRule ^/(.*) http://www.example.com/forum/forum/$1 [R=301,L]
答案 1 :(得分: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]