将目录重定向到新域而不触及主站点

时间:2013-09-06 06:11:57

标签: apache .htaccess redirect mod-rewrite

我想将https://mineyourmind.de/forum重定向到https://mineyourmind.net/forum

我可以google的每个重写规则都不起作用,他们还重定向了主域名(mineyourmind.de)。

我正在重定向http:// www。和http://和https://通过apache siteconfig。

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.mineoyurmind\.de$ [NC]
RewriteRule (.*) https://mienoyurmind.de%{REQUEST_URI} [R=301,L]

论坛目录的.htaccess如下所示:

ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 500 default

<IfModule mod_rewrite.c>
    RewriteEngine On

    #   If you are having problems with the rewrite rules, remove the "#" from the
    #   line that begins "RewriteBase" below. You will also have to change the path
    #   of the rewrite to reflect the path to your XenForo installation.
    #RewriteBase /xenforo

    #   This line may be needed to enable WebDAV editing with PHP as a CGI.
    #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L] 
</IfModule>

我应该将mineyourmind.de/forum的重写添加到mineyourmind.net/forum到apache站点配置还是htaccess,这应该怎么样?

1 个答案:

答案 0 :(得分:0)

如果您只想重定向/forum,那么您想添加此内容:

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.mineoyurmind\.de$ [NC]
RewriteRule ^forum/(.*) https://mienoyurmind.de%{REQUEST_URI} [R=301,L]

并将其添加到RewriteEngine On下方的htaccess文件中。