I have inherited support for an Opencart 1.5 site which needs to have SSL enabled.
I've edited the config.php files in / and admin/ and adding https:// to the URL is working in the browser and links are being generated with https
However, whatever method of an htaccess redirect I try seems to result in the site not loading.
The following is in the htaccess file and I suspect the problem is related to the last line here with route which I've not seen before.
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Any suggestions on how I can add https to this RewriteRule?
Thanks
Related
direct some pages to the homepage of opencart.
For examle:
https://mywebsitenamehere.com/index.php?route=product/manufacturer
301 redirect to:
https://mywebsitenamehere.com/
I would usually add something like this:
Redirect 301 /index.php?route=product/manufacturer https://mywebsitenamehere.com/
Snippet of my .htaccess:
# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/storage/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Thank you!!
Could you please try following, written and tested with shown samples. Please make sure you clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/storage/(.*) index.php?route=error/not_found [L]
RewriteCond %{QUERY_STRING} ^route=product/manufacturer [NC]
RewriteRule ^index\.php https://mywebsitenamehere.com [R=301,NC,L]
UPDATE:
in (for example)
manufacturer.php
add the following to the very top:
<?php // to redirect page
header( 'Location: https://mywebsitenamehere.com/' ) ;
?>
We have a website - https://www.leiebilguiden.no. A long time ago we changed to wordpress. There are still a lot of incoming links with a .php extension. For example https://www.leiebilguiden.no/spania/alicante.php.
The address that works now is https://www.leiebilguiden.no/spania/alicante/. Using htaccess and redirect how can we redirect all incoming links (not just the one above) with a php extension to a non php extension like seen above.
Thank you in advance for all answers.
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteEngine On
# browser requests PHP
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]
# check to see if the request is for a PHP file:
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/?(.*)$ /$1.php [L]
I use SEO URL on my opencart using .htaccess, now I want to redirect all non-www URL access to URL with www. So I add these lines in my .htaccess file:
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Yes now the URL is always redirected to www if it is written wihout www before my domain name, but I found something that I think it should not appear in the URL.
When I go to www.mydomain.com/category I tried to test that URL by removing the www (so it became mydomain.com/category) and hit ENTER. The URL was redirected to www.mydomain.com/index.php?_route_=category. I did not know what made the URL become like that, I think the URL should redirect to www.mydomain.com/category. I have tried to move the position of redirection lines before and after this line:
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Here is the full .htaccess content:
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
# Redirect non-www to www (I have tried to move this lines but still resulting the same)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
What is wrong with my redirection lines? Any help and suggestion would be appreciated. Thank you.
The issue is that you've put the rewrite for the domain too low down. Move it to just after the RewriteBase / and it will execute before the url rewrites do
RewriteBase /
# Redirect non-www to www (I have tried to move this lines but still resulting the same)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
on my .htaccess:
I tried to redirect a 404 page about_us page to about-us page using line code below
redirect 301 /about_us http://www.example.com/about-us
but when I tried to load to the browser for about-us page is redirect to this page to
http://www.example.com/about-us?_route_=about_us but still the page is in 404 error
here is my .htaccess rule
RewriteBase /
#RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
#RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Don't use redirect rule with mod_rewrite rules. Have it this way:
RewriteEngine On
RewriteBase /
RewriteRule ^about_us/?$ http://www.example.com/about-us [L,NC,R=301]
#RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
#RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Make sure to test in a new browser to avoid old browser cache.
I have restructure the website from WordPress to Opencart and so all URL has been changed. I am trying to redirect my old products page with new but it is not redirecting since OpenCart adding some weird ?route= and so on..
Here is my .htaccess
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Redirect 301 /store/products/old-item-name/ http://store.mydomain.com/new-item-name
It is redirecting to this weird url
http://store.mydomain.com/new-item-name?_route_=store/products/old-item-name/
I appreciate your great help.. million thanks
This is because the Redirect is part of mod_alias and everything else is part of mod_rewrite. The two modules get applied at different points of the URL-file processing pipeline, and in this case your request is getting applied by both modules. You need to move the redirect up to the top and stick to just mod_rewrite:
So remove:
Redirect 301 /store/products/old-item-name/ http://store.mydomain.com/new-item-name
and add this to the top:
RewriteRule ^products/old-item-name(/.*)$ http://store.mydomain.com/new-item-name$1 [L,R=301]
Last Redirect 301 rules is getting redirected by previous RewriteRule rule. In general its not advisable to mix mod_alias and mod_rewrite:
Try changing the last RewriteRule to this:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# your 301 rules from old to new
RewriteRule ^products/old-item-name(/.*|)$ new-item-name$1 [NC,L,R=301]
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase\.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(ico|gif|jpe?g|png|js|css)$ [NC]
RewriteRule ^(.*)$ index.php?_route_=$1 [L,QSA]
have just had a similiar problem when migrating from Ashop to OpenCart
the old urls were of the format
http://www.example.com/p/productid/manufacturer-productname.html
and were being redirected to
http://www.example.com/manufacturer/
the solutions was
RewriteRule ^(.*)manufacturer(-.*|)$ http://www.example.com/manufacturer/ [NC,L,R=301]
hope that helps someone.....
note you cannot directly match on manufacturer as a redirect loop will happen so match included the '-'