Apache如何重定向到其他端口



在使用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>

Giveshttp://192.168.178.99/:6830

如何删除链接

您可以使用重写规则来重定向它们,确保在您的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]

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

最新更新