AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 536891
Accepted
user2693017
user2693017
Asked: 2013-09-07 00:08:02 +0800 CST2013-09-07 00:08:02 +0800 CST 2013-09-07 00:08:02 +0800 CST

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

  • 772

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

我可以用谷歌搜索的每条重写规则都不起作用,他们还重定向了主域(mineyourmind.de)。

我重定向 http://www。和 http:// 和 https:// 通过 apache 站点配置。

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 中,这应该是什么样子?


编辑:

我试过这样:

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

像这样

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

两者都不起作用

apache-2.2
  • 1 1 个回答
  • 1083 Views

1 个回答

  • Voted
  1. Best Answer
    Jenny D
    2013-09-07T00:50:50+08:002013-09-07T00:50:50+08:00

    这是重定向以“/forum”开头的每个请求的规则。

    RewriteRule (/forum.*) https://mineyourmind.net/$1 [R=301,L]
    

    这意味着“当 URI 以“/forum”开头时,您应该捕获整个 URI,并将主机名替换为 mineyourmind.de。$1意思是“您刚刚匹配的内容”。

    编辑:

    为确保您不会重定向名称中以“forum”开头的任何文件,您可能需要两条规则。

    # To match /forum only:
    RewriteRule ^/forum$ https://mineyourmind.net/$1 [R=301,L] 
    # To match any URI under the /forum directory, e.g. "/forum/" and "/forum/someotherfile.html"
    RewriteRule ^/forum/(.*) https://mineyourmind.net/forum/$1 [R=301,L]
    

    编辑结束

    您是否应该在 .htaccess 或 apache 站点配置中执行此操作,取决于您的系统是如何设置的,即您存储其他特定于站点的文档的位置。一般来说,使用 .htaccess 时会有一点开销,因为 apache 会为每个新请求重新读取 .htaccess 文件,而站点配置只会在服务器重新启动时读取。但作为一项规则,我会尽可能将所有重写配置放在同一个文件中,以使其更易于管理。无论是 .htacces、virtualhost.conf 还是 httpd.conf,都取决于您。

    您还应该阅读RewriteRule 文档,其中解释了在什么情况下您需要/在 RewriteRule 中包含初始值。

    • 0

相关问题

  • Apache Django Mod_Wsgi - 自动重新加载应用程序

  • Apache:对多个虚拟主机使用相同的目录指令

  • Apache 上的子域不工作 - 找不到服务器

  • PHP 作为 CGI 还是 Apache 模块?

  • 避免将某些丢失的文件记录到 Apache2 错误日志中

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve