Cannot edit orders after change to https - OpenCart 2X - .htaccess

After changing into https and adding the following code to the .htaccess file:
RewriteCond %{HTTP_HOST} domainname\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.domainname.com/$1 [R,L]
I get a 'SytaxError:Unexpected end of JASON input error' when I want to edit an order.
When I revert to:
#RewriteCond %{HTTP_HOST} domainname\.com [NC]
#RewriteCond %{SERVER_PORT} 80
#RewriteRule ^(.*)$ https://www.domainname.com/$1 [R,L]
the error goes away and I can edit. But in this case, the website is not secure anymore and an unsafe sign appears at the top left side of the browser next to the address section.
I want to keep the site at https and still edit the orders. Can anyone help?
Thank you...!

Related

Url Rewrite get the error message HTTP errror 500

I use URL writing in the Web Server, after converting the URL provided by the user, and then passing it to the program processor in the Web Server. I have added .htaccess file in my domain folder root, like below the picture:
After I rewrite the rules in the .htaccess file, the error message is shown me:
This page isn’t working
www.everyoneknows.com.my is currently unable to handle this request.
HTTP ERROR 500
My problem sample
My website name which call is https://www.everyoneknows.com.my/customer/?loc=dashboard, this website is used PHP coding. I need to change last name ?loc=dashboard to dashboard. That means I want the result website name is https://www.everyoneknows.com.my/customer/dashboard
Below is my rewrite rules, but cannot work:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^everyoneknow\.com\.my [OR,NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.everyoneknows.com.my/$1 [R,L]
RewriteCond %{HTTP_HOST} ^everyoneknows\.com\.my [OR,NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.everyoneknows.com.my/$1 [R,L]
##External redirect to /customer/dashboard url rules here.
RewriteCond %{THE_REQUEST} \s/customer/?\?loc=(\S+)\s [NC]
RewriteRule ^ /customer/%1? [R=301,L]
##Internal rewrite rules to get it served by index.php file.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^customer/(.*)/?$ index.php?parameter=$1 [QSA,NC,L]
The result is shown like below picture:
If website name is https://www.everyoneknows.com.my/customer/?loc=dashboard, the result can run well:
Hope someone can guide me on how to solve this problem. Thanks.

how to allow ec2 health check through .htaccess while redirecting to https

I'm trying to create an .htaccess file that does the following:
1 Allows the EC2 health check URL to be hit without redirecting to https
2 Redirects all non-https traffic to https
3 Redirect calls to / to /auth/app/public/app (using https)
Items 2 and 3 work fine, but quickly the healthcheck fails and the server no longer responds. Here's the content of my .htaccess file:
RewriteEngine On
#one attempt that didn't work
#RewriteCond %{HTTP_HOST} !^my\.domain\.com$ [NC]
#RewriteCond %{REQUEST_URI} !^/healthcheck.html$
#RewriteRule ^ http://my.domain.com/$1 [R=301,L]
#another attempt that didn't work
#RewriteCond %{HTTP_HOST} !$ [NC]
#RewriteCond %{REQUEST_URI} !^/healthcheck.html$
#RewriteRule ^(.*)$ /$1 [L,QSA]
#this works
RewriteRule ^$ https://my.domain.com/auth/app/public/app/ [L]
#this works
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://my.domain.com%{REQUEST_URI} [L]
The first two commented-out attempts are from examples I found at https://serverfault.com/questions/470015/how-should-i-configure-my-elb-health-check-when-using-namevirtualhosts-and-redir
and https://serverfault.com/questions/470015/how-should-i-configure-my-elb-health-check-when-using-namevirtualhosts-and-redir/597541#597541
Please let me know if you have any suggestions how I can get this working.
Thank you for the reply. Before I read that, I found another post that provided a solution that is working for me. I simply added another condition to not apply the https redirect rule if the url was that of my health check page. Here is the working version of my .htaccess file:
RewriteEngine On
RewriteRule ^$ https://my.domain.com/auth/app/public/app/ [L]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{REQUEST_URI} !^/healthcheck\.html$
RewriteRule ^ https://my.domain.com%{REQUEST_URI} [L]

.htaccess redirect involving SSL

RewriteCond %{REQUEST_URI} !/(market|other|available|areas)/ [NC]
RewriteRule ^(.*)$ /market/$1 [R=301,L]
As you can see, I currently have my htaccess setup so that any page that tries to be accessed but does not exist, will resort back to /market/, along with going to the original domain example.com, will redirect to example.com/market/ while the other designated directories are also still available.
My simple question is, if I activate an SSL on my account, would there be anything to change with this? or does this not listen to http or https but simply the directory redirects?
Thanks!
-- EDIT --
As I kind of suspected, the original rewrite didn't pay attention to the http/https (thank you Panama Jack). Would this solution work? as it first checks to goto https, and then will send off to the /market/ directory?
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
RewriteCond %{REQUEST_URI} !/(market|other|available|areas)/ [NC]
RewriteRule ^(.*)$ /market/$1 [R=301,L]

Redirect only sub pages using htaccess

I have a website (WordPress multisite) for which I've moved a bunch of content from the route domain (http://domain[dot]com) to a sub domain (http://sub.domain[dot]com). Now I need to direct users to all the pages of the route site (http://domain[dot]com/page) to their new location (http://sub.domain[dot]com/page). But... and here's the bit I'm really struggling with... I need to omit the route url from this re-write as there is another 'geo-redirect' in place that I need to not affect. What I need to do therefore is redirect ONLY those sub page and NOT the parent/main domain.
Here's (a recent iteration) of what I'm working with:
# ignore the home page, not working :(
RewriteCond %{HTTP_HOST} !^(.*)\.routetogreatness\.com$ [NC]
# redirect all the sub pages, works
RewriteCond %{HTTP_HOST} ^routetogreatness.com [NC]
RewriteRule ^(.*)$ http://global.routetogreatness.com/$1 [L,R=301]
Any help will be very gratefully received.
I think what you are searching for is a condition that checks if the file that is requested is not a filename. That's what RewriteCond %{REQUEST_FILENAME} !-f. It is true if %{REQUEST_FILENAME} (I believe an absolute path to a file on the server, based on the request), is not a file. (Please note: I haven't tested this code as I don't have access to a server at this location, but I think it should work.)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://sub.domain.com/$1 [L,R=301]
An other solution would be to only rewrite the url if the requested url contains a slash. It would redirect domain.com/folder/index.php, but not domain.com/index.php.
RewriteCond %{REQUEST_URI} ^/([^/]+)/(.+)$
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://sub.domain.com/$1 [L,R=301]
Okay, so the above solution didn't quite work out for me as it turned out that while this worked beautifully on sub/child page, it would skip over parent pages as well as the home page (like domain/news for example. I've eventually run with this:
RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://sub.domain.com/$1 [L,R=301]
This just skips over the home page or root URL and redirects everything else, even 404s.

stuck on htaccess rewrite url

i've been stuck on this for a few weeks, i think i'm close now, but i'm stuck on syntax for htcaccess..
here's what i'm trying to do: user types in site.com and is redirected to subdomain.wordpresshost.com; however the address bar still says site.com (i also want to keep anything after this point such as/blog.html etc)
nameserver is all set, now i'm just rewriting urls... heres the best code i have come up with.. it's just not working
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain.wordpresshost.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^site.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.site.com$ [NC]
RewriteRule ^(.*)$ http://www.site.com/$1 [L,R=301]
This code successfully changes subdomain.wordpresshost.com to site.com; however, it returns an error stating either 'server unavailable' or 'too many redirects'
I think i've hit my head against the keyboard so that I'm just making static noise, so i'd appreciate any help!
The last RewriteCond is unnecessary and is creating the redirection loop - www.site.com is rewritten to www.site.com… maybe you meant the non-www. Either way, it needs to be removed.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain.wordpresshost.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^site.com$ [NC]
RewriteRule ^(.*)$ http://www.site.com/$1 [L,R=301]

Resources