2015-06-02 65 views
0

我已经使用搜索和谷歌,但似乎无法找到解决方案。我试图将其重定向到HTTPS,但遇到一些问题。我不断收到:如何解决htaccess ssl https重定向?

ERR_TOO_MANY_REDIRECTS

下面是我的htaccess文件。我宁愿不要为每个html代码添加代码。我已经尝试了一切,只是无法弄清楚。

# Multiple Environment config 
# Set this to development, staging or production 
# SetEnv PYRO_ENV production 
<IfModule mod_rewrite.c> 

    # Make sure directory listing is disabled 
    Options +FollowSymLinks -Indexes 
    # disable the Apache MultiViews directive if it is enabled on the server. It plays havoc with URL rewriting 
    Options -MultiViews 
    RewriteEngine on 
     RewriteCond %{HTTPS} !=on 
     RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

    RedirectMatch 403 ^/.*/(system/cms/cache|system/codeigniter|system/cms/config|system/cms/logs|\.git|\.hg).*$ 

    # Send request via index.php (again, not if its a real file or folder) 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 

    <IfModule mod_php5.c> 
     RewriteRule ^(.*)$ index.php/$1 [L] 
    </IfModule> 

    <IfModule !mod_php5.c> 
     RewriteRule ^(.*)$ index.php?/$1 [L] 
    </IfModule> 

</IfModule> 

编辑:问题解决了下面曾任职代码。请锁定

RewriteCond %{ENV:HTTPS} !on [NC] 
RewriteRule ^(.*)$ https://mydomain(dot)com/$1 [R,L] 
+0

请你分享网址? – Avinash

+0

http://gateway-webhosting.ca在这里你去:p – user3732612

回答

0

尝试下面的代码,它应该工作:

<IfModule mod_rewrite.c> 
    Options +FollowSymLinks -Indexes 
    Options -MultiViews 

    RewriteEngine On 
    RewriteCond %{HTTPS} !on 
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

    RedirectMatch 403 ^/.*/(system/cms/cache|system/codeigniter|system/cms/config|system/cms/logs|\.git|\.hg).*$ 

    # Send request via index.php (again, not if its a real file or folder) 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 
+0

你好,谢谢你的回复我试过这个代码,你给了我,但我仍然得到完全相同的错误 – user3732612

+0

@ user3732612你可以做的就是尝试将http放置到https相关重定向并删除所有其他部分。并逐渐加入其他规则。这样你可以找到有问题的路线。 – Avinash

+0

好,如果我单独使用Rewritecond它可以工作,但是然后我的pyrocms错误没有休息。 – user3732612