【问题标题】:How to make redirection from one URL to another URL in apache如何在apache中从一个URL重定向到另一个URL
【发布时间】:2015-12-29 08:19:13
【问题描述】:

如何在 apache 中从一个 URL 重定向到另一个 URL? 在文件 httpd.conf..

我需要做以下事情: - 用户打开站点“server.com” - 用户自动被重定向到“app.server.com”

我怎样才能做到?

【问题讨论】:

    标签: apache httpd.conf


    【解决方案1】:

    在 .htacces 文件中输入这个

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^server\.com$ [NC]
    RewriteRule ^(.*)$ http://app.server.com/$1 [R=301,L]
    

    RewriteCond %{HTTP_HOST} ^server\.com$ [NC] 中保留\. 并且不要用. 替换它很重要,因为\. 是一个转义点。

    【讨论】:

    • 什么是.htacces 文件?我只有 httpd.conf
    • .htaccess 文件是由 http 服务器解释的文件。在您的 webroot 中创建文件名.htaccess,当客户端尝试加载与 .htaccess 相同的文件夹或同一文件夹的子文件夹中的任何内容时,它将首先读取 .htaccess。如果您在 webroot 上创建一个名为 .htaccess 的文件并确保它包含以下内容:RewriteEngine on RewriteCond %{HTTP_HOST} ^server\.com$ [NC] RewriteRule ^(.*)$ http://app.server.com/$1 [R=301,L] 如果将所有客户端从 server.com 重定向到 app.server.com
    猜你喜欢
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 2013-03-13
    • 2020-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多