Laravel -- windows apache .htaccess https 路由重写

一:

 

 

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{SERVER_PORT} !^443
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

  RewriteRule ^(.*)/$ /public/$1 [L,R=301]
  RewriteRule ^ index.php [L]

</IfModule>

 

二:

  

 

  

Web 服务器配置

关于虚拟主机的配置(映射域名到Laravel应用目录)略过,如果了解细节可参考这篇教程,当然也可以留待下一篇讲 Homestead 和 Valet 再去了解。本文只探讨如何美化 URL 让其更具有可读性。

Apache

框架中自带的 public/.htaccess 文件支持隐藏 URL 中的 index.php,如过你的 Laravel 应用使用 Apache 作为服务器,需要先确保 Apache 启用了mod_rewrite 模块以支持 .htaccess 解析。

如果 Laravel 自带的 .htaccess 文件不起作用,试试将其中内容做如下替换:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Nginx

如果你使用的是 Nginx,使用如下站点配置指令就可以支持 URL 美化:

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

地址:Laravel中文网  https://laravelacademy.org/post/7620.html




At last 如果使用一不可行 换二试试

 

 

 

 

 

转载于:https://www.cnblogs.com/gjh99/p/10793735.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值