Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make phpcms support https

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to make phpcms support https". In daily operation, I believe many people have doubts about how to make phpcms support https. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to make phpcms support https"! Next, please follow the editor to study!

1. If you have installed phpcms, you need to replace the configuration options in caches/configs/system.php by replacing "http://" all with" https://". If necessary, links that already exist in the database should also be completely replaced with the beginning of https.

2. Program modification:

(1) modify the regularity of about 45 and 128lines of phpcms/modules/admin/site.php

('/ http:\ /\ / (. +)\ / $/ domain))

Modify to

('/ (http | https):\ /\ / (. +)\ / $/ domain)

(2) modify the regularity in about 18 lines of phpcms/modules/admin/templates/setting.tpl.php

Http:\ /\ / (. +) [^ /] $

Modify to

Http [s]?:\ /\ / (. +) [^ /] $

(3) modify the regularity in about 13 lines of phpcms/modules/admin/templates/site_add.tpl.php

Http:\ /\ / (. +)\ / $

Modify to

Http [s]?:\ / / (. +)\ / $

(4) modify the regularity in about 11 lines of phpcms/modules/admin/templates/site_edit.tpl.php

Http:\ /\ / (. +)\ / $

Modify to

Http [s]?:\ / / (. +)\ / $

(5) modify the regularities in approximately 41 and 51 lines of phpcms/modules/link/index.php

/ ^ http:\ /\ / (. *) / I

Modify to

/ ^ http [s]?:\ / / (. *) / I

(6) modify the regularity in about 10 lines of phpcms/modules/link/templates/link_add.tpl.php

^ http:\ /\ / [A-Za-z0-9] +\. [A-Za-z0-9] + [\ / =\?%\ &] * ([^]) * $

Modify to

^ http [s]?:\ /\ / [A-Za-z0-9] +\. [A-Za-z0-9] + [\ / =\?%\-&] * ([^]) * $

(7) modify the regularity in about 11 lines of phpcms/modules/link/templates/link_edit.tpl.php

^ http:\ /\ / [A-Za-z0-9] +\. [A-Za-z0-9] + [\ / =\?%\ &] * ([^]) * $

Modify to

^ http [s]?:\ /\ / [A-Za-z0-9] +\. [A-Za-z0-9] + [\ / =\?%\-&] * ([^]) * $

After strictly following the above steps, the registration of user account login and other operations are completely normal, PHPSSO communication is completely normal, background information and foreground link URL are completely normal.

Note:

a. If the registered user prompts "operation failed", please turn off "optional member model when registering" in the background member module settings or ensure that there are no less than two member models.

b. In the PHP version of PHP5.6 or above, it will not be able to communicate with PHPSSO normally, because functions such as PHP5.6 and above fsockopen and file_get_contents need to verify whether the target SSL certificate is trusted, and you need to install the opensl root certificate, otherwise openssl will report a warning that certificate verification failed!

If you need to use HTTPS in php5.6 or above, please refer to PHP's official information on php5.6 and openssl http://php.net/manual/en/migration56.openssl.php

3. After the above modification, the content in phpcms can be accessed through https, but there is a paging error. The solution is:

Open the file phpcms\ libs\ functions\ global.func.php and find the location of line 738:

$url = str_replace ('http://','//','~'), array (' ~','/', 'http://'), $url)

Modify to

$url = str_replace ('https://','//','~'), array (' ~','/', 'https://'), $url)

After the above three steps, phpcms perfectly supports https. Combined with page static and url pseudo-static rules, https can also be used for testing static pages.

At this time, the website is actually accessible through both http and https.

Add:

After all the above steps, a new problem arises: the news list page clicks on the title to jump to the URL that will repeat the website domain name. The solution is as follows:

Open phpcms\ modules\ content\ templates\ content_list.tpl.php and locate line 97:

Strpos ($r ['url'],' http://')!==false

Modified to:

Strpos ($r ['url'],' https://')!==false) at this point, the study on "how to make phpcms support https" is over. I hope you can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report