doudai8783 2018-06-12 02:08 采纳率: 100%
浏览 88
已采纳

在SocialEngine 4.2.9中将htaccess修改为https重定向后,重定向过多问题[重定向循环]

Recently I have installed the ssl certificate for our domain. And as part of https secure redirection, changed the htaccess to redirect to https. It works fine with the home page. But when I am login as a user or as an admin, the redirection fails and getting a message like too many redirects and page loading is failed due to redirect looping back and forth between https and http. Please help me to solve this issue.

Please find the current htaccess file that I am using

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On

  RewriteCond %{SERVER_PORT} 80
  RewriteRule ^(.*)$ https://www.flatparty.com/$1 [R,L]

  RewriteRule ^(blog)($|/) - [L]

  # Get rid of index.php
  RewriteCond %{REQUEST_URI} /index\.php
  RewriteRule (.*) index.php?rewrite=2 [L,QSA]

  # Rewrite all directory-looking urls
  RewriteCond %{REQUEST_URI} /$
  RewriteRule (.*) index.php?rewrite=1 [L,QSA]

  # Try to route missing files
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} public\/ [OR]
  RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
  RewriteRule . - [L]

  # If the file doesn't exist, rewrite to index
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA]

</IfModule>

When I access https://www.flatparty.com it works fine. But once I logged in gets the redirection issue.

  • 写回答

2条回答 默认 最新

  • doumou1864 2018-06-28 05:25
    关注

    Finally I got the fix for the issue !!. It was not the issue with .htaccess content, it was the issue with the server code. The following code was the reason for the redirect loop issue.

    $host = $_SERVER['HTTP_HOST'];
    $request_uri = $_SERVER['REQUEST_URI'];
    $good_url = "http://" . $host . $request_uri;
    
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: $good_url");
    

    The .htaccess code is working fine and whenever htaccess redirects url to https and the above mentioned code gets redirected to http and eventually it leads to an infinite loop and request will never completes.

    Thanks for the help and suggestions.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。