我的网站使用IP打开,但我需要将IP重定向到域。
我使用Laravel框架创建项目。
我的服务器是 Ubuntu 16.04
我的.htaccess是://此文件是根文件夹
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L]
RewriteCond %{HTTPS_HOST} ^10\.10\.10\.10
RewriteRule (.*) https://website.com/$1 [R=301,L]
</IfModule>
但是这段代码不适用于我。
谢谢
答案 0 :(得分:0)
这样做:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTPS_HOST} !^website\.com$ [NC]
RewriteRule ^ https://website.com%{REQUEST_URI} [R=301,L,NE]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://website.com%{REQUEST_URI} [L,R=301,NE]
答案 1 :(得分:0)
只需在http.conf file
的末尾写。
ip重定向到<Virtualhost *:80>
<VirtualHost *:80>
ServerName < Server_hostname >
ServerAlias *
Redirect / https://< Server_hostname >/
</VirtualHost>
##https://ip redirection to domain name under the <Virtualhost *:443>
<VirtualHost *:443>
ServerName < Server_hostname >
ServerAlias *
Redirect / https://< Server_hostname >/
</VirtualHost>