Post by RJLab3 » Wed May 12, 2021 10:30 pm

I've upgraded to v3.0.3.7. I have SEO URL's working but for account pages etc the urls are still
mywebsite.com/index.php?route=account/account
How do I change it so it's just
mywebsite.com/account
I've googled and googled, downloaded extensions but nothing seems to work.

Any help would be much appreciated.

Newbie

Posts

Joined
Fri Mar 27, 2020 3:56 pm

Post by RJLab3 » Wed May 12, 2021 11:06 pm

Just to clarify - The SEO works fine. So mywebsite.com/account - actually loads.

What I mean is, all the links on the website need to be changed.

Newbie

Posts

Joined
Fri Mar 27, 2020 3:56 pm

Post by straightlight » Wed May 12, 2021 11:37 pm

.htaccess file.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by RJLab3 » Wed May 12, 2021 11:43 pm

what do i need to add to that?

Newbie

Posts

Joined
Fri Mar 27, 2020 3:56 pm

Post by straightlight » Wed May 12, 2021 11:43 pm

RJLab3 wrote:
Wed May 12, 2021 11:43 pm
what do i need to add to that?
First, you just need to enable it and test it.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by RJLab3 » Wed May 12, 2021 11:49 pm

i added this line to the htaccess file;

RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

Is that meant to fix the problem?

Newbie

Posts

Joined
Fri Mar 27, 2020 3:56 pm

Post by straightlight » Wed May 12, 2021 11:53 pm

RJLab3 wrote:
Wed May 12, 2021 11:49 pm
i added this line to the htaccess file;

RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

Is that meant to fix the problem?
Clear the browsing history and test it on the browser.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by RJLab3 » Wed May 12, 2021 11:59 pm

nope, still nothing. any other suggestions?

Newbie

Posts

Joined
Fri Mar 27, 2020 3:56 pm

Post by straightlight » Thu May 13, 2021 12:01 am

RJLab3 wrote:
Wed May 12, 2021 11:59 pm
nope, still nothing. any other suggestions?
Please post your full .htaccess file.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by RJLab3 » Thu May 13, 2021 12:35 am

# 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 Directory listing
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "(?i)((\.tpl|\.twig|\.ini|\.log|(?<!robots)\.txt))">
Require all denied
## For apache 2.2 and older, replace "Require all denied" with these two lines :
# 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=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]

### 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

Newbie

Posts

Joined
Fri Mar 27, 2020 3:56 pm

Post by mikeinterserv » Thu May 13, 2021 1:34 am

Take a look at this for another idea
https://webocreation.com/blog/remove-ro ... and-other/

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by paulfeakins » Thu May 13, 2021 4:34 pm

straightlight wrote:
Thu May 13, 2021 12:01 am
RJLab3 wrote:
Wed May 12, 2021 11:59 pm
nope, still nothing. any other suggestions?
Please post your full .htaccess file.
You keep talking about the .htaccess file but you've misread the question.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Guru Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by paulfeakins » Thu May 13, 2021 4:34 pm

RJLab3 wrote:
Wed May 12, 2021 11:06 pm
Just to clarify - The SEO works fine. So mywebsite.com/account - actually loads.

What I mean is, all the links on the website need to be changed.
Find an SEO extension for this.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Guru Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by straightlight » Thu May 13, 2021 7:28 pm

paulfeakins wrote:
Thu May 13, 2021 4:34 pm
straightlight wrote:
Thu May 13, 2021 12:01 am
RJLab3 wrote:
Wed May 12, 2021 11:59 pm
nope, still nothing. any other suggestions?
Please post your full .htaccess file.
You keep talking about the .htaccess file but you've misread the question.
Nevertheless. People can still use SEO and not enable the .htaccess file since the odds of people knowing that on first sight without using the forums are pretty low on anyhow.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Johnathan » Thu May 13, 2021 9:15 pm

RJLab3, if you want an easier solution, Rewrite Manager can do this. It will modify the URLs in the system as well as let the new pages work. You can remove any page's "index.php?route=" portion, and then enter your own SEO Keyword for the page instead.

Feel free to take a look at the screenshots and demo site, and if you're interested let me know at www.getclearthinking.com/contact if you have any questions.

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by RJLab3 » Fri May 14, 2021 7:46 pm

mikeinterserv wrote:
Thu May 13, 2021 1:34 am
Take a look at this for another idea
https://webocreation.com/blog/remove-ro ... and-other/
That seems to work but only on account/register and account/login - which I find strange.
On other pages like information/sitemap it comes up with a "page not found."

Any ideas?

Newbie

Posts

Joined
Fri Mar 27, 2020 3:56 pm

Post by mikeinterserv » Fri May 14, 2021 8:37 pm

You can change any url you want
Just make sure you followed the method correctly and completely

Code: Select all

if ($data['route'] == 'information/sitemap'){
    $url .= '/sitemap';
}
Add as many URLs as you want in here and its rewrite URL. Then go to admin >> Design >> SEO URL and add them

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by by mona » Fri May 14, 2021 8:45 pm

Changing mywebsite.com/index.php?route=account/account into mywebsite.com/account has nothing to do with SEO.

No url for the account/* and checkout/* paths should ever be indexed by search engines and as such making them SEO is futile. Unless you are attempting to make them HBO (Human Being Optimized) urls.
Then you still have to add them manually, after extending the seo_url class to enable rewriting additional paths.

PS. don't forget to do the additional work of adding all of those HBO urls to your robots.txt file, in all languages you may have.
RJLab3 wrote:
Fri May 14, 2021 7:46 pm
Any ideas?
Johnathan wrote:
Thu May 13, 2021 9:15 pm
RJLab3, if you want an easier solution, Rewrite Manager can do this. It will modify the URLs in the system as well as let the new pages work. You can remove any page's "index.php?route=" portion, and then enter your own SEO Keyword for the page instead.
Which is really usefully generally as well as going forward rather than having to do and remember what you need to edit manually

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by by mona » Sat May 15, 2021 8:26 am

If you are not comfortable changing code OCMOD-wise or otherwise, use the mentioned extension.
If you are comfortable, use this and make a back-up:

file: catalog/controller/startup/seo_url.php

Code: Select all

function: rewrite
change this:

Code: Select all

foreach ($data as $key => $value) {
			if (isset($data['route'])) {
				if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/info' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id')) {
					$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");

					if ($query->num_rows && $query->row['keyword']) {
						$url .= '/' . $query->row['keyword'];

						unset($data[$key]);
					}
				} elseif ($key == 'path') {
					$categories = explode('_', $value);

					foreach ($categories as $category) {
						$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = 'category_id=" . (int)$category . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");

						if ($query->num_rows && $query->row['keyword']) {
							$url .= '/' . $query->row['keyword'];
						} else {
							$url = '';

							break;
						}
					}

					unset($data[$key]);
				}
			}
		}

to this:

Code: Select all

foreach ($data as $key => $value) {
			if (isset($data['route'])) {
				if (($data['route'] == 'product/product' && $key == 'product_id') || (($data['route'] == 'product/manufacturer/info' || $data['route'] == 'product/product') && $key == 'manufacturer_id') || ($data['route'] == 'information/information' && $key == 'information_id')) {
					$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
					if ($query->num_rows && $query->row['keyword']) {
						$url .= '/' . $query->row['keyword'];
						unset($data[$key]);
					}
				} elseif ($key == 'path') {
					$categories = explode('_', $value);
					foreach ($categories as $category) {
						$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = 'category_id=" . (int)$category . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
						if ($query->num_rows && $query->row['keyword']) {
							$url .= '/' . $query->row['keyword'];
						} else {
							$url = '';
							break;
						}
					}
					unset($data[$key]);
				/**********************************************************************/	
				/* additional code enabling route seo urls and removing common/home from root url */
				/**********************************************************************/
				} elseif (!in_array($data['route'],array('common/language/language','common/currency/currency','product/product','product/category','product/manufacturer/info','information/information'))) {
					// all other cases for route settings & eliminating unnecessary queries (seo urls already generates a truckload of queries for rewriting)
					if ($key == 'route') {
						// no need to query root
						if ($value == 'common/home') {
							$url = '/';
						} else {
							$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE `query` = '" . $this->db->escape($value) . "' AND store_id = '" . (int)$this->config->get('config_store_id') . "' AND language_id = '" . $this->config->get('config_language_id') . "'");
							if ($query->num_rows) {
								if ($url != '/') $url .= '/';
								$url .= $query->row['keyword'];
								unset($data[$key]);
							}
						}
					}
				}
			}
		}

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am
Who is online

Users browsing this forum: No registered users and 22 guests