.htaccess - What you do?
Autor: Sinisa B.In order my site to load in a https:/ manner - I had to add the following code in the .htaccess file in the root of my site (between the # comments made by WSX5):
# WebSite X5 - Start Code [do not edit]
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
# WebSite X5 - End Code
But upon every update via WSX5 - I have to re-upload the same .htaccess file on my server because the upload process will replace the file!
Do you know how to prevent this?
Is there some way that my hosting provider could "arrange" so my site would automatically load in a https protocol?
****
BTW - in the newest (2020.2) version the .htaccess file content has changed and when I add the above code (between the # marks) - my site won't load at all (I got SERVER ERROR message)!
Thank you very much for your inputs!
Hi,
Try to do this (it's what I do for all my projects and I have no problem):
# WebSite X5 - Start Code [do not edit]
# WebSite X5 - End Code
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
Tell me if it is ok for you.
Sincerely,
Danielle
Hello Sinisa,
Please follow Danielle's advice, which will resolve your issue.
The hash tags are used as markers to delimit the sections of code which are reserved for use by WebSite X5. Any code which you place between these tags is liable to be overwritten on subsequent uploads to the server.
You can add your own code freely, but it must lie outside the hash tags.
Kind regards,
Paul
Search the WebSite X5 Help Center
Autor
@ FABRE Danielle and @ Paul
Thank you for your comments!
***
It seems that the WSX5 - in the upload process - removes the whole .htaccess file, regardless of where I put the code...
...I got a message while uploading - it goes something like this>
"The .htaccess file will be removed/replaced would you like to continue?"
WebSite X5 should neither edit nor delete any of your own code, and in previous versions this has always worked flawlessly for me. I will try to run some tests for you, Sinisa. Perhaps there is an issue in the new version which has not come to light yet.
Please bear with me.
I can't recreate the problem, Sinisa, and I have tried all sorts of combinations. I've tested in version 2020.2
It's normal to get a message warning that the .htaccess file will be modified, if you have selected or deselected any options in WebSite X5 which affect the .htaccess file. But this in itself is not a problem. If you inspect the contents of the .htaccess file before and after upload you will see that WebSite X5 never deletes any code which you have added yourself.
So although the software does modify the .htaccess file, it will always ensure that your original code is retained.
Providing, of course, that your original code does not lie inside the hash tags which are used by WebSite X5 when parsing the file.
Autor
@ Paul
Thank you for your effort!
Ok - so the key is that any custom coding of the .htaccess file should go OUTSIDE the # (comment)... Again, thanks a lot!
Autor
@ Paul and @FABRE Danielle
When I put the above code OUTSIDE the # in the .htaccess file - I got the following error:
*****
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at *** to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
*****
I had to remove/delete the .htaccess file so that my site could be accessible!
The ONLY thing that works (checked 5 minutes ago) is when my .htaccessfile had this content (inside the #) - and NO OTHER CONTENT (i.e. PHP info) otside the #!:
*****
# WebSite X5 - Start Code [do not edit]
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
# WebSite X5 - End Code
*****
Do you know guys what is going on?
Thx!
Hello Sinisa,
I use this in my htacces file;
# WebSite X5 - Start Code [do not edit]
# WebSite X5 - End Code
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.yourwebsiteadress\.com|yourwebsiteadress\.com)$ [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://yourwebsiteadress.com/$1 [R,L]
AddHandler x-httpd-php71 .php
.com can also be different and yourwebsiteadress is offcource your own website adress of the root of your website.
Hope this helps!
Autor
@ Andre
I'll try and report here!
Thank you!
Autor
@ Andre
It works - thank you very much!
Very nice!
Thanks for the feedback.