Jurg
Jurg

Reputation: 9

Apache how to redirect to other port?

On a rpi with Apache i want to redirect port 80 to port 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>

Gives http://192.168.178.99/:6830

How can I remove / from the link

Upvotes: 0

Views: 327

Answers (1)

Example person
Example person

Reputation: 3346

You can use rewrite rules to redirect them, make sure mod_rewrite is enabled in your apache, add it to .htaccess or httpd.conf :

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

If you only want to redirect index.php, use this:

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

Let me know if it doesn't work :)

Upvotes: 2

Related Questions