【问题标题】:Apache how to redirect to other port?Apache如何重定向到其他端口?
【发布时间】:2021-04-09 10:13:01
【问题描述】:

在使用 Apache 的 rpi 上,我想将端口 80 重定向到端口 6830。 index.html;

    <! -- Redirect to port  -->
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Page</title>
<meta name="generator" content="WYSIWYG Web Builder 15 - http://www.wysiwygwebbuilder.com">
<meta http-equiv="refresh" content="0; URL=:6830">
</head>
<body>
<div id="wb_Heading1" style="position:absolute;left:46px;top:19px;width:522px;height:69px;z-index:0;">
<h1 id="Heading1">Untitled Page</h1></div>
</body>
</html>

http://192.168.178.99/:6830

如何从链接中删除 /

【问题讨论】:

  • 尝试给出准确的 URL 而不是端口。
  • 您使用的是什么操作系统?
  • 我不能给出确切的 url,rpi 会根据网络获取一个 url
  • 它将所有80端口的页面重定向到6830端口

标签: html apache redirect


【解决方案1】:

您可以使用重写规则来重定向它们,确保在您的 apache 中启用 mod_rewrite,将其添加到 .htaccess 或 httpd.conf :

RewriteEngine on
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^.*$ http://%{HTTP_HOST}:6830%{REQUEST_URI} [R=301,L]

如果你只想重定向 index.php,使用这个:

RewriteEngine on
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{REQUEST_URI} ^\/index.php$
RewriteRule ^.*$ http://%{HTTP_HOST}:6830%{REQUEST_URI} [R=301,L]

如果它不起作用,请告诉我:)

【讨论】:

    猜你喜欢
    • 2014-10-06
    • 1970-01-01
    • 1970-01-01
    • 2019-02-02
    • 2014-12-02
    • 1970-01-01
    • 2017-07-24
    • 1970-01-01
    • 2012-01-22
    相关资源
    最近更新 更多