Post by webfeetdesign » Mon Feb 09, 2015 3:47 pm

I have my OC version 2 set up on the root level of my domain. The older version of the shop was in a folder called /buy-online. I have tried performing a 301 Redirect using htaccess but all I get is this in the explorer bar...

Code: Select all

http://www.foliages.ae/?_route_=buy-online
It appears to automatically be adding ?_route_= to anything I try and redirect. Has anyone come across this before?

My site is live now and there are lots of pages registered with Google but they all point to my old site and I need to get it sorted asap. Any help with this would be much appreciated.

Active Member

Posts

Joined
Fri Feb 05, 2010 1:28 am
Location - Dubai

Post by cwswebdesign » Mon Feb 09, 2015 10:58 pm

It has to do with the ordering of the coding in your .htaccess file. Move the 301 redirects above the following rules:

#Put your 301 Redirects here and then follow up with the rules below

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]

This account is inactive. Look for us under the name 'EvolveWebHosting' and contact us under that username.

Thanks!


User avatar
Active Member

Posts

Joined
Sun Dec 11, 2011 12:26 am
Location - USA

Post by webfeetdesign » Mon Feb 09, 2015 11:13 pm

Hi, I tried that but it didn't work. What is the minimum I need to have in the htaccess file to get the seo urls to work? This is what I have currently...

Code: Select all

# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
# 2. In your opencart directory rename htaccess.txt to .htaccess.
# For any support issues please visit: http://www.opencart.com
Options +FollowSymlinks
# Prevent Directoy listing 
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
 Order deny,allow
 Deny from all
</FilesMatch>
# 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=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [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]
### Additional Settings that may need to be enabled for some servers 
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.
# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off
# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off
# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M
# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M
# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200
# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200
# 7. disable open_basedir limitations
# php_admin_value open_basedir none

redirect 301 /buy-online http://www.foliages.ae/


Active Member

Posts

Joined
Fri Feb 05, 2010 1:28 am
Location - Dubai

Post by cwswebdesign » Tue Feb 10, 2015 3:23 am

Are you trying to get SEO URLs to work or 301 Redirects to work?

This account is inactive. Look for us under the name 'EvolveWebHosting' and contact us under that username.

Thanks!


User avatar
Active Member

Posts

Joined
Sun Dec 11, 2011 12:26 am
Location - USA

Post by webfeetdesign » Tue Feb 10, 2015 4:08 pm

I'm trying to get 301 Redirects to work. My SEO Urls are working fine.

Active Member

Posts

Joined
Fri Feb 05, 2010 1:28 am
Location - Dubai

Post by webfeetdesign » Tue Feb 10, 2015 6:21 pm

Has anyone else ran into this problem before?

Active Member

Posts

Joined
Fri Feb 05, 2010 1:28 am
Location - Dubai

Post by labeshops » Tue Feb 10, 2015 9:31 pm

Actually I did and fixed it by moving the lines cwswebdesign told you to do (I told him this lol).

Your rewrite lines MUST be in the rewriterule section, not at the bottom of the file, so your section in htaccess should look like:

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
redirect 301 /buy-online http://www.foliages.ae/
// add any other rewrite rules you need here
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]

Running Opencart v3.0.3.2 with multi-stores and the default template from https://www.labeshops.com which has links to all my stores.


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by webfeetdesign » Wed Feb 11, 2015 12:06 pm

Thanks Labeshops. Can you advise as to the exact htaccess code i should have to do the following:

Friendly Urls for Opencart 2
Redirect 301 /buy-online http://www.foliages.ae

The code I have at the minute is below but it's confusing. I'd rather just have in exactly what I need. Thanks for your help.

You can test it by typing www.foliages.ae/buy-online (I still get the default 404 page)

Code: Select all

# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
# 2. In your opencart directory rename htaccess.txt to .htaccess.
# For any support issues please visit: http://www.opencart.com
Options +FollowSymlinks
# Prevent Directoy listing 
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
 Order deny,allow
 Deny from all
</FilesMatch>
# 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=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
redirect 301 /buy-online http://www.foliages.ae/ 
### add any other rewrite rules you need here
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]
### Additional Settings that may need to be enabled for some servers 
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.
# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off
# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off
# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M
# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M
# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200
# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200
# 7. disable open_basedir limitations
# php_admin_value open_basedir none


Active Member

Posts

Joined
Fri Feb 05, 2010 1:28 am
Location - Dubai

Post by webfeetdesign » Thu Feb 12, 2015 12:03 pm

I will test it again maybe without the friendly urls to see if that is what is causing the issue.

Active Member

Posts

Joined
Fri Feb 05, 2010 1:28 am
Location - Dubai

Post by labeshops » Thu Feb 12, 2015 12:32 pm

Sorry, I'm not that familiar with the syntax - I just copied it from some online examples when I did mine.

Running Opencart v3.0.3.2 with multi-stores and the default template from https://www.labeshops.com which has links to all my stores.


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by webfeetdesign » Thu Feb 12, 2015 1:48 pm

Ok thanks. Anyone else willing to chip in??

Active Member

Posts

Joined
Fri Feb 05, 2010 1:28 am
Location - Dubai

Post by qahar » Thu Feb 12, 2015 6:30 pm

add code below after googlebase.xml rewriterule. It's work on my local test

Code: Select all

RewriteRule ^buy-online$ http://www.foliages.ae/ [R=301,L]

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by webfeetdesign » Thu Feb 12, 2015 7:54 pm

That's great, thanks. How come this works but normal Redirect 301 won't? Any reason. Really appreciate this Qahar

Active Member

Posts

Joined
Fri Feb 05, 2010 1:28 am
Location - Dubai

Post by qahar » Fri Feb 13, 2015 1:15 am

The reason is mod_rewrite rules always executed before mod_alias.
So before your 301 redirect executed, rewriterule _route_ is applied

There is great tutorial for this: here

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by webfeetdesign » Fri Feb 13, 2015 1:20 pm

Thank you. Does it matter how many

Code: Select all

RewriteRule ^buy-online$ http://www.foliages.ae/ [R=301,L]
I use? I have basically listed all of my 301 redirects in this format.

Active Member

Posts

Joined
Fri Feb 05, 2010 1:28 am
Location - Dubai
Who is online

Users browsing this forum: No registered users and 295 guests