Im爲我的網站使用以下.htaccess。如果它們不是位於url的文件,我將所有的url重定向到index.php。將htaccess重寫爲https,路線爲
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)。
這很好,只是我想強制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
添加了這個,它的工作。謝謝!你能解釋爲什麼cloudflare需要這種不同的待遇嗎? – 2014-10-16 14:17:05
@KenHendriks你沒有一個真正的ssl連接到你的服務器,只能從客戶端到CloudFlare。從CloudFlare到您的服務器的連接是正常的http連接,所以您的原始解決方案無法正常工作。但是,CloudFlare會添加一個http頭,以便您可以檢查訪問者是否請求了http或https連接,並且這是您在我的答案中看到的CloudFlare'CF-Visitor'標頭。 – jeroen 2014-10-16 14:19:26