WebSite X5Help Center

 
Syed A.
Syed A.
User

Hi, I am using Website X5 Evolution 9, please advise me a way to a way to force ssl on all pages without using a redirect.  en

Author: Syed A.
Visited 2367, Followers 2, Shared 0  

http://www.sanhat.com.pk/

Hi, I am using Website X5 Evolution 9, please advise me a way to a way to force ssl on all pages without using a redirect.

Posted on the
5 ANSWERS - 1 USEFUL - 1 CORRECT
Paul M.
Paul M.
Moderator

Hello Syed,

Not possible as far as I'm aware without using a redirect.

You could redirect either through use of your .htaccess file on your server, or through the PHP header() function.

But if for some reason you don't want to do either of those then you will have to change all links in your X5 project to point to the alternative secure URL:

http://www.sanhat.com.pk/

becomes

https://www.sanhat.com.pk/

Kind regards,

Paul

Read more
Posted on the from Paul M.
Syed A.
Syed A.
User
Author

Thanks a lot. Please also advise how I can do the same with PHP header() function?

Read more
Posted on the from Syed A.
Paul M.
Paul M.
Moderator

You could put the following code in the head section of each page which you wish to redirect.  The code needs to be at the very top of the page, before any display or output is sent to the browser:

<?php

if ($_SERVER['SERVER_PORT'] != "443")
{header('Location: https://www.sanhat.com.pk/pagename.php'); exit;}

?>

Obviously you will need to substitute 'pagename.php' for the name of each page on your site to which you are adding this code in the header.

You need to change the file extension of each of your pages to .php (from .html) to ensure that the PHP code runs.

Hope this helps.

Kind regards,

Paul

Read more
Posted on the from Paul M.
Syed A.
Syed A.
User
Author

Please also tell me how can I change all links in X5 project to point to the alternative secure URL:

Read more
Posted on the from Syed A.
Paul M.
Paul M.
Moderator
Syed A.
Please also tell me how can I change all links in X5 project to point to the alternative secure URL:

You mean using the .htaccess file?  To be honest it's much simpler and straightforward to do it that way.

#Redirect HTTP to HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

Put that code in the .htaccess file on your server, and you can forget about PHP header redirects.  It's a lot less editing to do in X5 that way.  Each and every page will automatically be redirected to the HTTPS version, and you won't have to remember to add PHP code to the header each time you add a new page to your website.

Does that help?

Paul

Read more
Posted on the from Paul M.