: Redirect example.com:81 to example.com I need to redirect www.example.com:81/site/ to www.example.com. I have used mod_rewrite a few times, is it possible to solve this in a similar way?
I need to redirect example.com:81/site/ to example.com. I have used mod_rewrite a few times, is it possible to solve this in a similar way?
More posts by @Hamaas447
4 Comments
Sorted by latest first Latest Oldest Best
Below is the code you can use in .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ example.com:81/ [P]
</IfModule>
This might do what you are looking for:
RewriteEngine on
RewriteCond %{SERVER_PORT} ^81$ # check if port 81
RewriteCond %{REQUEST_URI} ^site/ # check if it starts with "site/"
RewriteRule .* %{SERVER_NAME}%{REQUEST_URI} [R,L]
[R=301,L] if you want permanent redirect (the :81 taken out of SEO results for example).
Im not really sure if you have to add :80 after the %{SERVER_NAME}, please let me know so I can update the answer.
On example.com:81 create .htaccess file (where site/ is):
RewriteEngine on
RewriteRule (.*) example.com:80/ [P,L]
With this when you go to example.com:81 the site will proxy to example.com.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.