Highlighted

Issue with redirect script

Participant ,
Oct 02, 2018

Copy link to clipboard

Copied

So this is a bit of an odd one. I have a site which has been http. We recently switched to an https for it. Our hosting service has said there's no way that they can redirect it for us (even though the domains and SSL are also through them). They directed us to insert this code into our site in order to redirect it.

<script language="javascript">
if (document.location.protocol != "https:")
{
document.location.href = "
https://subdomain.yourdomain.com" + document.location.pathname;
};
</script>

The code works and the site redirects. However, when I enter the code...the page goes a bit wonky in Live View and I get one of two errors (see screen grab). The only way I can go in and make any visual changes is to switch to design mode or remove the script entirely. Any thoughts?broken.JPGbroken2.JPG

Adobe Community Professional
Correct answer by Nancy OShea | Adobe Community Professional

I would use a permanent rewrite rule at the server level.

On Linux hosting, you can usually do this manually in your .htaccess  file.  Or via your server's C-panel. 

Redirecting HTTP to HTTPS Using .htaccess File: Step by Step Guide

On Windows hosting, look at your Plesk Panel.

Views

274

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Issue with redirect script

Participant ,
Oct 02, 2018

Copy link to clipboard

Copied

So this is a bit of an odd one. I have a site which has been http. We recently switched to an https for it. Our hosting service has said there's no way that they can redirect it for us (even though the domains and SSL are also through them). They directed us to insert this code into our site in order to redirect it.

<script language="javascript">
if (document.location.protocol != "https:")
{
document.location.href = "
https://subdomain.yourdomain.com" + document.location.pathname;
};
</script>

The code works and the site redirects. However, when I enter the code...the page goes a bit wonky in Live View and I get one of two errors (see screen grab). The only way I can go in and make any visual changes is to switch to design mode or remove the script entirely. Any thoughts?broken.JPGbroken2.JPG

Adobe Community Professional
Correct answer by Nancy OShea | Adobe Community Professional

I would use a permanent rewrite rule at the server level.

On Linux hosting, you can usually do this manually in your .htaccess  file.  Or via your server's C-panel. 

Redirecting HTTP to HTTPS Using .htaccess File: Step by Step Guide

On Windows hosting, look at your Plesk Panel.

Views

275

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 02, 2018 0
Adobe Community Professional ,
Oct 02, 2018

Copy link to clipboard

Copied

I would use a permanent rewrite rule at the server level.

On Linux hosting, you can usually do this manually in your .htaccess  file.  Or via your server's C-panel. 

Redirecting HTTP to HTTPS Using .htaccess File: Step by Step Guide

On Windows hosting, look at your Plesk Panel.

Nancy O'Shea, ACP
Alt-Web Design & Publishing

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 02, 2018 0
Participant ,
Oct 02, 2018

Copy link to clipboard

Copied

So...I have since learned that the instructions my hosting site gave me was...incomplete. There's still no clear explanation as to if this code was supposed to be actually entered into the page code (though that's what they said).

They have now, as you mentioned, suggested the .htaccess file. Except that this particular hosting service has hidden or made it impossible to find said cPanel. Yeah, I've gone and talked to my IT person about switching hosting servers as he's been fighting them for other reasons.

Until then I'm stuck trying to make this mess work.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 02, 2018 0
Adobe Community Professional ,
Oct 02, 2018

Copy link to clipboard

Copied

Are you on Mac or Windows?  .htaccess files are typically hidden from view on Macs (I don't know why).

But you can see them on your remote server if you're on Windows PC.

GET  the server's  .htaccess file, open and add the  rewrite rule.

Save and upload to your server's root folder.

Nancy O'Shea, ACP
Alt-Web Design & Publishing

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 02, 2018 0
Participant ,
Oct 02, 2018

Copy link to clipboard

Copied

I'm on windows. When I asked where my cPanel was (I inherited this mess) I was told we didn't hate one and the only way I could see the .htaccess file was through an FTP client, but not all clients worked and I'd have to figure that out myself. They're super helpful.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 02, 2018 0
Adobe Community Professional ,
Oct 02, 2018

Copy link to clipboard

Copied

Here's a workaround that might do the trick for you in Live View...

Go to View > Live View Options > Hide Live View Displays
Go back into View > Live View Options > Disable Javascript
Switch From Live to Design and back again to make sure DW shows the page without the redirect

That "should" keep Live View from running your redirect javascript and allow you to see what you're doing, though you won't have the handy blue outlines around everything when you click items. From what I understand, those are also run by javascript and need to be turned off before the option to disable JS even activates.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 02, 2018 0
Participant ,
Oct 02, 2018

Copy link to clipboard

Copied

So I've found the .htaccess file and it was empty. I got it to work with the tutorial you sent. Thanks! Sorry about the mild ranting on evil web hosts.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 02, 2018 0