首页 > 解决方案 > .htaccess index php / html 重定向到主页面

问题描述

我有这个.htaccess。我想:

我怎样才能做到?

我的过程:

  RewriteEngine On
     # Redirect to non www
     RewriteCond% {HTTP_HOST} ^ www.domena.pl $ [NC]
     RewriteRule ^ (. *) $ Https://domena.pl/$1 [R = 301, L] 

标签: laravelapache.htaccess

解决方案


使用 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]

推荐阅读