我使用codeigniter,我使用重定向所有网址到https。现在我想只将一个页面(https://www.example.com/campaign/PPRTasshs-dhshs_fd5656dfhdh/web/surf)重定向到http。
我在So中得到了很多答案。但我无法正确实施它。每次我收到错误“此网页有一个重定向循环”。
我的htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# the subsequent rule will catch it.
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
RewriteCond %{SERVER_PORT} 443
RewriteCond $1 (web\/surf|surf)
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^about-us / [L,R=301]
Options -Indexes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
链接以便我尝试但不为我工作。
Codeigniter: Check and force one page to https://
Redirect single page http to https
提前致谢
答案 0 :(得分:1)
您必须在https重定向更改条件。并在https://www
重定向检查额外条件。只需尝试以下代码。这可能对你有帮助。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# the subsequent rule will catch it.
**RewriteCond $1 !(web\/surf|surf)**
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
RewriteCond %{SERVER_PORT} 443
RewriteCond $1 (web\/surf|surf)
RewriteRule ^(.*)$ http://www.traffictraject.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.
**RewriteCond $1 !(web\/surf|surf)**
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^about-us / [L,R=301]
Options -Indexes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
答案 1 :(得分:0)
听起来你的ssl和非ssl版本的网页来回重定向,这就是你获得重定向循环的原因。您需要为重定向添加额外条件。没有检查,但它应该工作。
http
- &gt; https
重定向也将此条件置于
RewriteCond %{REQUEST_URI} !/campaign/PPRTasshs-dhshs_fd5656dfhdh/web/surf
这应该可以防止重定向循环
重定向https - &gt; http检查on
的HTTPS条件,并通过删除!
RewriteCond %{REQUEST_URI} /campaign/PPRTasshs-dhshs_fd5656dfhdh/web/surf
然后重定向到http
答案 2 :(得分:0)
我希望这会有所帮助。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# the subsequent rule will catch it.
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !campaign/PPRTasshs-dhshs_fd5656dfhdh/web/surf
RewriteRule ^(.*)$ https://www.yourdomain.com%{REQUEST_URI} [L,R=301]
Options -Indexes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteRule ^about-us / [L,R=301]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>