laravel - .htaccess index php / html 重定向到主页面
问题描述
我有这个.htaccess。我想:
- 他会从www.domena.pl直接指向domena.pl(我已经完成了)以始终指向 https
- 进入 domena.pl/index php 或 index html 后 -> 重定向到 https domena.pl
我怎样才能做到?
我的过程:
RewriteEngine On
# Redirect to non www
RewriteCond% {HTTP_HOST} ^ www.domena.pl $ [NC]
RewriteRule ^ (. *) $ Https://domena.pl/$1 [R = 301, L]
解决方案
使用 https 重定向到非 www:
RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)
RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]
让所有路由都转到 index.php:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
推荐阅读
- node.js - Heroku:process.env.NODE_ENV 未注册为“生产”(它注册为“开发”)
- c++ - 使用 ShellExecute 打开程序后无法运行
- alexa - 我正在尝试创建一个快速简报技能。但是每次我部署我的技能时都会出错
- c# - xUnit 不会在 Visual Studio 2017 中以 32 位模式运行
- compilation - 为什么在 Alpine 上使用 musl 编译失败而在 ArchLinux 上编译成功
- android - 无法在 kotlin 中为 android 应用程序设置 intellij
- php - 在php中明智地打印年份范围
- python - 无法使用地理(Python)从文本中提取城市名称
- string - 将基于文本的日期转换为 dd/mm/yyyy
- jmeter - 致命警报:记录本机移动应用程序时 jmeter 中的证书未知