2016-01-12 125 views
0

你好這一切都是我的htaccess,我有我的https我想重定向所有非https到HTTPS,而不會影響我的get/post變量和任何其他鏈接只是簡單地將網站移動到HTTPS重定向所有非https請求https請求由htaccess

htaccess文件

RewriteEngine On 
    RewriteBase/
    Options All -Indexes 
    RewriteCond %{REQUEST_METHOD} POST [NC] 
    RewriteRule^- [L] 
    ErrorDocument 403 /www.domain.com/error404.php 
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.*$ [NC] 


    RewriteCond %{HTTP_HOST} !^www\. 
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 

    # redirect /profile?eid=1 to /eid/1 
    RewriteCond %{THE_REQUEST} \s/+profile(?:\.php)?\?(eid)=(\d+)\s [NC] 
    RewriteRule^/%1/%2? [R=301,L] 

    # internally rewrite /eid/1 to /profile.php?eid=1 
    RewriteRule ^(eid)/(\d+)$ profile.php?$1=$2 [L,QSA,NC] 



    # redirect /dept?did=1 to /did/1 
    RewriteCond %{THE_REQUEST} \s/+dept(?:\.php)?\?(did)=(\d+)\s [NC] 
    RewriteRule^/%1/%2? [R=301,L] 

    # internally rewrite /did/1 to /dept.php?did=1 
    RewriteRule ^(did)/(\d+)$ dept.php?$1=$2 [L,QSA,NC] 

    RewriteCond %{THE_REQUEST} \s/+enterprise\.php\?url=([^\s&]+) [NC] 
    RewriteRule^/%1? [R=301,L] 

    RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC] 
    RewriteRule^/%1 [R=302,L,NE] 

    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC] 
    RewriteRule ^(.+?)/?$ $1.php [L] 

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.+)$ enterprise.php?url=$1 [L,QSA] 

我試圖folling代碼添加到我的htaccess文件

RewriteCond %{HTTPS} !on 
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 

,但該網站出錯頁面,但在HTTPS模式

我加入後htaccess的頁403錯誤處理程序中的代碼..

我不是htaccess的請建議我一些洙好.. 只是在第一次嘗試的網站重定向到HTTPS不是在http

回答

3

你應該告訴redirect使用R flag並提供狀態code這將有助於您的搜索引擎優化。使此規則成爲您的第一條規則

Options All -Indexes 
    RewriteEngine On 
    RewriteBase/
    RewriteCond %{HTTPS} !on 
    RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 
    #all other rules below 
相關問題