子域上的混合内容-如何替换HTTP元链接到https一个

时间:2018-12-28 07:39:56

标签: php

我有一个PHP网站,我正在研究一个演示子域social.searchika.com,在这里我通过HTTPS获得混合内容。主域没有任何问题,并且工作正常。问题仅在子域上。

这是我的config.php中的代码:

// MySQL Hostname
$sql_db_host = "localhost";
// MySQL Database User
$sql_db_user = "root";
// MySQL Database Password
$sql_db_pass = "";
// MySQL Database Name
$sql_db_name = "deepak_social";

// Site URL
$site_url = "http://social.searchika.com"; // e.g http://example.com

它加载了混合内容(HTTPS和HTTP URL)

当我将HTTPS放入URL时,出现以下错误:

此页面无法正常工作。social.searchika.com重定向了您太多次。

这就是我的索引文件中的内容:

if ($wo['loggedin'] == true) {
  $update_last_seen = Wo_LastSeen($wo['user']['user_id']);
} else if (!empty($_SERVER['HTTP_HOST'])) {
  $server_scheme = @$_SERVER["HTTPS"];
  $pageURL = ($server_scheme == "on") ? "https://" : "http://";
  $http_url = $pageURL . $_SERVER['HTTP_HOST'];
  $url = parse_url($wo['config']['site_url']);
  if (!empty($url)) {
    if ($url['scheme'] == 'http') {
      if ($http_url != 'http://' . $url['host']) { 
        header('Location: ' . $wo['config']['site_url']);
        exit();
      }
    } else {
      if ($http_url != 'https://' . $url['host']) { 
        header('Location: ' . $wo['config']['site_url']);
        exit();
    }
  }

}

nginx.conf看起来像这样

# nginx configuration

location / {
  if (!-e $request_filename){
    rewrite ^/password-reset/([^\/]+)(\/|)$ /index.php?link1=welcome&link2=password_reset&user_id=$1;
  }
  rewrite ^/$ /index.php?link1=home;
  rewrite "^/forum/members/([a-zA-Z]{0,1})(/?|)$" /index.php?link1=forum-members-byname&char=$1;
  if (!-e $request_filename){
    rewrite ^/setting/([A-Za-z0-9_]+)/([A-Za-z0-9_-]+)$ /index.php?link1=setting&user=$1&page=$2;
    rewrite ^/setting/([A-Za-z0-9_-]+)$ /index.php?link1=setting&page=$1;
    rewrite ^/setting$ /index.php?link1=setting;
  }
  if (!-e $request_filename){
    rewrite ^/@([^\/]+)(\/|)$ /index.php?link1=timeline&u=$1;
  }
  if (!-e $request_filename){
    rewrite ^/([A-Za-z0-9_]+)/([^\/]+)(\/|)$ /index.php?link1=timeline&u=$1&type=$2;
  }
  if (!-e $request_filename){
    rewrite ^/([^\/]+)(\/|)$ /index.php?link1=timeline&u=$1;
  }
}

location /admin {
  rewrite ^/admin-cp$ /admincp.php;
  rewrite ^/admin-cp/(.*)$ /admincp.php?page=$1;
  rewrite ^/admin/ads/edit/(\d+)(/?|)$ /index.php?link1=manage-ads&id=$1;
}

location = /admincp {
  rewrite ^(.*)$ /admincp.php;
}

location /admincp {
  rewrite ^/admincp/(.*)$ /admincp.php?page=$1;
}

location /adminPages/ {
  return 301 /admin-panel/;
}

location ~ ^/adminPages/(.*) {
    return 301 /admin-panel/$1;
}

location /start {
  rewrite ^/start-up$ /index.php?link1=start-up;
}

location /saved {
  rewrite ^/saved-posts/(.*)$ /index.php?link1=saved-posts;
  rewrite ^/saved-posts$ /index.php?link1=saved-posts;
}

location /activated {
  rewrite ^/activated/(.*)$ /index.php?link1=activate&link2=$1;
}

location = /search {
  rewrite ^(.*)$ /index.php?link1=search;
}

location /ads {
  rewrite ^/ads-create$ /index.php?link1=ads-create;
  rewrite ^/ads(/?|)$ /index.php?link1=ads;
  rewrite ^/ads/create(/?|)$ /index.php?link1=create-ads;
  rewrite ^/ads/edit/(\d+)(/?|)$ /index.php?link1=edit-ads&id=$1;
  rewrite ^/ads/chart/(\d+)(/?|)$ /index.php?link1=chart-ads&id=$1;
}

location /send_money {
  rewrite ^/send_money$ /index.php?link1=ads-create;
}

location = /most_liked {
  rewrite ^(.*)$ /index.php?link1=most_liked;
}

location /suggested {
  rewrite ^/suggested-pages(/?|)$ /index.php?link1=suggested-pages;
  rewrite ^/suggested-groups(/?|)$ /index.php?link1=suggested-groups;
}

location = /poke {
  rewrite ^(.*)$ /index.php?link1=poke;
}

location /search {
  rewrite ^/search/([^\/]+)(\/|)$ /index.php?link1=search&query=$1;
}

location /app {
  rewrite ^/app/([^\/]+)(\/|)$ /index.php?link1=app&app_id=$1;
}

location /messages {
  rewrite ^/messages/([^\/]+)(\/|)$ /index.php?link1=messages&user=$1;
}

location /terms {
  rewrite ^/terms/([^\/]+)(\/|)$ /index.php?link1=terms&type=$1;
}

location /video {
  rewrite ^/video-call/([^\/]+)(\/|)$ /index.php?link1=video-call&call_id=$1;
  rewrite ^/video-call-api/([^\/]+)(\/|)$ /index.php?link1=video-call-api&call_id=$1;
}

location /post {
  rewrite ^/post/([^\/]+)(\/|)$ /index.php?link1=post&id=$1;
}

location /game {
  rewrite ^/game/([^\/]+)(\/|)$ /index.php?link1=game&id=$1;
}

location = /upgraded {
  rewrite ^(.*)$ /index.php?link1=upgraded;
}

location = /get_news_feed {
  rewrite ^(.*)$ /index.php?link1=get_news_feed;
}

location = /games {
  rewrite ^(.*)$ /index.php?link1=games;
}

location /new {
  rewrite ^/new-game$ /index.php?link1=new-game;
  rewrite ^/new-product$ /index.php?link1=new-product;
}

location /go {
  rewrite ^/go-pro$ /index.php?link1=go-pro;
}

location = /oops {
  rewrite ^(.*)$ /index.php?link1=oops;
}

location /user {
  rewrite ^/user-activation$ /index.php?link1=user-activation;
}

location /hashtag {
  rewrite ^/hashtag/([^\/]+)(\/|)$ /index.php?link1=hashtag&hash=$1;
}

location /follow {
  rewrite ^/follow-requests/(.*)$ /index.php?link1=follow-requests;
}

location = /home {
  rewrite ^(.*)$ /index.php?link1=home;
}

location = /404 {
  rewrite ^(.*)$ /index.php?link1=404;
}

location /welcome {
  rewrite ^/welcome(.*)$ /index.php?link1=welcome;
}

location = /register {
  rewrite ^(.*)$ /index.php?link1=register;
}

location /confirm {
  rewrite ^/confirm-sms$ /index.php?link1=confirm-sms;
  rewrite ^/confirm-sms-password(/?|)$ /index.php?link1=confirm-sms-password break;
}

location /forgot {
  rewrite ^/forgot-password$ /index.php?link1=forgot-password;
}

location = /activate {
  rewrite ^(.*)$ /index.php?link1=activate;
}

location = /pages {
  rewrite ^(.*)$ /index.php?link1=pages;
}

location = /groups {
  rewrite ^(.*)$ /index.php?link1=groups;
}

location /create {
  rewrite ^/create-group$ /index.php?link1=create-group;
  rewrite ^/create-page$ /index.php?link1=create-page;
  rewrite ^/create-album$ /index.php?link1=create-album;
  rewrite ^/create-album/([A-Za-z0-9_-]+)$ /index.php?link1=create-album&album=$1;
  rewrite ^/create-blog(/?|)$ /index.php?link1=create-blog;
  rewrite ^/create-app$ /index.php?link1=create-app;
}

location = /logout {
  rewrite ^(.*)$ /index.php?link1=logout;
}

location /contact {
  rewrite ^/contact-us$ /index.php?link1=contact-us;
}

location = /messages {
  rewrite ^(.*)$ /index.php?link1=messages;
}

location = /albums {
  rewrite ^(.*)$ /index.php?link1=albums;
}

location /albums {
  rewrite ^/albums/([A-Za-z0-9_-]+)$ /index.php?link1=albums&user=$1;
}

location /album {
  rewrite ^/album/([A-Za-z0-9_-]+)$ /index.php?link1=album&id=$1;
}

location /page {
  rewrite ^/page-setting/([^\/]+)(\/|)$ /index.php?link1=page-setting&page=$1;
  rewrite ^/page-setting/([A-Za-z0-9_]+)/([A-Za-z0-9_-]+)$ /index.php?link1=page-setting&page=$1&link3=$2;
}

location /group {
  rewrite ^/group-setting/([^\/]+)(\/|)$ /index.php?link1=group-setting&group=$1;
  rewrite ^/group-setting/([A-Za-z0-9_]+)/([A-Za-z0-9_-]+)$ /index.php?link1=group-setting&group=$1&link3=$2;
}

location /edit {
  rewrite ^/edit-product/([A-Za-z0-9_]+)$ /index.php?link1=edit-product&id=$1;
  rewrite ^/edit-blog/(\d+)(/?|)$ /index.php?link1=edit-blog&id=$1;
}

location = /products {
  rewrite ^(.*)$ /index.php?link1=products;
}

location /products {
  rewrite ^/products/([A-Za-z0-9_-]+)$ /index.php?link1=products&c_id=$1;
}

location /my {
  rewrite ^/my-products$ /index.php?link1=my-products;
  rewrite ^/my-blogs(/?|)$ /index.php?link1=my-blogs;
}

location /site {
  rewrite ^/site-pages/(.*)$ /index.php?link1=site-pages&page_name=$1;
}

location = /blogs {
  rewrite ^(.*)$ /index.php?link1=blogs;
}

location = /sharer {
  rewrite ^(.*)$ /index.php?link1=sharer;
}

location /blog {
  rewrite ^/blog-category/(\d+)(/?|)$ /index.php?link1=blog-category&id=$1;
}

location /read {
  rewrite ^/read-blog/(.*)$ /index.php?link1=read-blog&id=$1;
}

location = /app_api {
  rewrite ^(.*)$ /index.php?link1=app_api;
}

location /api {
  rewrite ^/api(/?|)$ /api-v2.php;
  rewrite ^/api/([^\/]+)(\/|)$ /api-v2.php?type=$1;
}

location = /authorize {
  rewrite ^(.*)$ /index.php?link1=authorize;
}

location /forum {
  rewrite ^/forum(/?|)$ /index.php?link1=forum;
  rewrite ^/forum/members(/?|)$ /index.php?link1=forum-members;
  rewrite ^/forum/search(/?|)$ /index.php?link1=forum-search;
  rewrite ^/forum/search-result/(/?|)$ /index.php?link1=forum-search-result;
  rewrite ^/forum/events(/?|)$ /index.php?link1=forum-events;
  rewrite ^/forum/help(/?|)$ /index.php?link1=forum-help;
}

location /forums {
  rewrite ^/forums/(\d+)(/?|)$ /index.php?link1=forums&fid=$1;
  rewrite ^/forums/add/(\d+)(/?|)$ /index.php?link1=forumaddthred&fid=$1;
  rewrite ^/forums/thread/(\d+)(/?|)$ /index.php?link1=showthread&tid=$1;
  rewrite ^/forums/thread/reply/(\d+)(/?|)$ /index.php?link1=threadreply&tid=$1;
  rewrite ^/forums/thread/quote/(\d+)(/?|)$ /index.php?link1=threadquote&tid=$1;
  rewrite ^/forums/thread/edit/(\d+)(/?|)$ /index.php?link1=editreply&tid=$1;
  rewrite ^/forums/user/threads(/?|)$ /index.php?link1=mythreads;
  rewrite ^/forums/user/threads/edit/(\d+)(/?|)$ /index.php?link1=edithread&tid=$1;
  rewrite ^/forums/user/messages(/?|)$ /index.php?link1=mymessages;
}

location /events {
  rewrite ^/events(/?|)$ /index.php?link1=events;
  rewrite ^/events/create-event(/?|)$ /index.php?link1=create-event;
  rewrite ^/events/edit/(\d+)/(/?|)$ /index.php?link1=edit-event&eid=$1;
  rewrite ^/events/my(/?|)$ /index.php?link1=my-events;
  rewrite ^/events/going(/?|)$ /index.php?link1=events-going;
  rewrite ^/events/invited(/?|)$ /index.php?link1=events-invited;
  rewrite ^/events/interested(/?|)$ /index.php?link1=events-interested;
  rewrite ^/events/past(/?|)$ /index.php?link1=events-past;
  rewrite ^/events/(\d+)(/?|)$ /index.php?link1=show-event&eid=$1;
}

location /movies {
  rewrite ^/movies(/?|)$ /index.php?link1=movies;
  rewrite ^/movies/genre/([A-Za-z-]+)(/?|)$ /index.php?link1=movies-genre&genre=$1;
  rewrite ^/movies/country/([A-Za-z-]+)(/?|)$ /index.php?link1=movies-country&country=$1;
  rewrite ^/movies/watch/(\d+)(/?|)$ /index.php?link1=watch-film&film-id=$1;
}

location /wallet {
  rewrite ^/wallet(/?|)$ /index.php?link1=wallet;
}

location /status {
  rewrite ^/status/create(/?|)$ /index.php?link1=create-status;
}

location /more {
  rewrite ^/more-status(/?|)$ /index.php?link1=more-status;
}

location /friends {
  rewrite ^/friends-nearby(/?|)$ /index.php?link1=friends-nearby;
}

location /_ {
  rewrite ^/_$ /requests.php;
}

location /graph {
  rewrite ^/graph-success$ /index.php?link1=graph-success;
}

location = /developers {
  rewrite ^(.*)$ /index.php?link1=developers;
}

location = /apps {
  rewrite ^(.*)$ /index.php?link1=apps;
}

location = /graph {
  rewrite ^(.*)$ /index.php?link1=graph;
}

location = /oauth {
  rewrite ^(.*)$ /index.php?link1=oauth;
}

location /boosted {
  rewrite ^/boosted-pages$ /index.php?link1=boosted-pages;
  rewrite ^/boosted-posts$ /index.php?link1=boosted-posts;
}

我也遇到了登录n的多个问题;

我能找到的最简单的解决方案是用https版本替换URL,因为造成问题的链接仅是元标记,但即使我找不到文件中所有元标记的源代码在哪里,请劝告。谢谢!

0 个答案:

没有答案