Post by matt71 » Tue Dec 13, 2016 1:01 am

Hello

I'm looking to do a redirect of the native contact form (/index.php?route=information/contact) to my own contact form (/contact) using mod_rewrite.

I have the following in my .htaccess file, but it doesn't appear to work. Any suggestions would be appreciated?

Code: Select all

Redirect 301 /index.php?route=information/contact http://www.mywebsite.com/contact
Thanks
Matt

New member

Posts

Joined
Sat Jan 19, 2013 4:13 am

Post by angela » Tue Dec 13, 2016 1:38 am

In:
catalog/controller/startup/seo_url.php:

Find:

Code: Select all

} elseif ($key == 'path') {
Replace with:

Code: Select all

					} elseif ($data['route'] == 'information/contact') {

						$url .= '/contact';
						
						unset($data[$key]);
						
					} elseif ($key == 'path') {
Remove what you did in your .htaccess, and above this:

Code: Select all

RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
add:

Code: Select all

RewriteRule ^contact$ index.php?route=information/contact [L]
No need to do a 301 to achieve what you are trying to do.
You can also duplicate the syntax to do all of the default non-SEO url's to make them prettier by changing the route & htaccess flags accordingly.

Keep in mind, if you edit the controller directly, you'll need to re-apply your fixes when you upgrade your OpenCart install, so always keep a backup.

User avatar
New member

Posts

Joined
Fri Dec 02, 2016 2:14 am

Post by simonpieman » Tue Dec 13, 2016 1:53 am

Angela is right

For redirect rule you can add the type of redirect at the end,. i.e.

your code [NC,R=301,L]

Go the All Blacks!


Active Member

Posts

Joined
Thu Jul 02, 2015 8:58 am
Location - NZ - Auckland

Post by matt71 » Tue Dec 13, 2016 6:22 am

Thanks for the reply. Do I need to change the controller code or can I just revise the htaccess?

Matt

New member

Posts

Joined
Sat Jan 19, 2013 4:13 am

Post by angela » Wed Dec 14, 2016 3:00 am

matt71 wrote:Thanks for the reply. Do I need to change the controller code or can I just revise the htaccess?

Matt
Both, else it won't work properly.

Back up before you edit - that way if something goes wrong, easy to undo.
Back up after, because when you upgrade you'll need to re-apply.

User avatar
New member

Posts

Joined
Fri Dec 02, 2016 2:14 am

Post by QuinnD » Thu Dec 22, 2016 9:02 pm

Thank you angela ... I am not OP but this answered the question i needed answering..

This isnt needed now as i have done this using separate code for each page as described above but for future reference and to cut down the lines of code needed how can you put all similar URLs into an array, then use a variable for the seo_url.php code

ie, all the account/* urls
product/*
common/*
information/*
ECT.

and the htaccess rewite code would need to pick up the variable used for each page type like it does for products and categories

Thanks

Newbie

Posts

Joined
Tue Dec 20, 2016 8:46 pm
Who is online

Users browsing this forum: No registered users and 23 guests