首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >如何在https://domain中将IP重定向到.htaccess

如何在https://domain中将IP重定向到.htaccess
EN

Stack Overflow用户
提问于 2017-03-18 10:59:10
回答 2查看 1.7K关注 0票数 0

我的网站开放的IP,但我需要重定向IP到域名。

我用Laravel框架创建项目。

我的服务器是Ubuntu16.04

我的.htaccess是: //这个文件是根文件夹

代码语言:javascript
代码运行次数:0
运行
复制
<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>

但这个密码不适用于我。

谢谢

EN

回答 2

Stack Overflow用户

发布于 2017-03-18 11:13:36

以这种方式:

代码语言:javascript
代码运行次数: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]
票数 0
EN

Stack Overflow用户

发布于 2018-08-12 10:51:36

只需在http.conf file的末尾写。ip重定向到<Virtualhost *:80>下的域名

代码语言:javascript
代码运行次数:0
运行
复制
<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>    
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42873457

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档