簡體   English   中英

apache .htcaccess重定向到https

[英]apache .htcaccess redirect to https

當我這樣做時,將登錄頁面重定向到https時遇到問題:

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{HTTPS} off
RewriteRule ^login https://sklep.galmet.com.pl/login [L,R=301]

# otherwise forward it to index.php
RewriteRule . index.php

這可以在我轉到shop.abcdomain.com.pl/logn重定向到https://shop.abcdomain.com.pl/logn ,但未加載.css.jpeg等所有文件,我認為是因為這行的RewriteRule . index.php RewriteRule . index.php但我不知道該如何解決

RewriteCond僅適用於它涉及的第一個規則..因此,對文件/目錄的檢查不適用於不傳遞給index.php的情況。 嘗試這個:

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{HTTPS} off
RewriteRule ^login https://sklep.galmet.com.pl/login [L,R=301]

# otherwise forward it to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

開始時將所有資產(css / js)文件鏈接為“ /”,即可正常運行。

將此添加到您的apache .htcaccess文件中

1.-選項FollowSymLinks
2.-選項+多視圖

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM