【发布时间】:2014-12-11 21:56:53
【问题描述】:
我正在为我的网站使用以下 .htaccess。如果它们不是位于 url 的文件,我会将所有 url 重定向到 index.php。
Options +FollowSymLinks
IndexIgnore */*
# Turn on the RewriteEngine
RewriteEngine On
# Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
这样http://website.com/user/user_name/ 会转到 index.php 和 http://website.com/css/style.css 给出了实际的 css 文件(如果 style.css 存在的话)。
这很好用,只是我想在 url 上强制 https:// 并且我无法让它工作。任何帮助是极大的赞赏。
编辑:
使用 Jeroen 的回答,我得到了它与以下 .htaccess 的配合
Options +FollowSymLinks
IndexIgnore */*
# Turn on the RewriteEngine
RewriteEngine On
# Rules
RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"'
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
【问题讨论】:
标签: php .htaccess mod-rewrite https