Zen Cart Logo
Forums / General Questions / htaccess redirect

htaccess redirect

Views: 1,398

Results 1 to 4 of 4
9 May 2014, 4:51 PM
#1
kevin205 avatar

kevin205

Totally Zenned

Join Date:
Dec 2012
Posts:
607
Plugin Contributions:
0

htaccess redirect

I am trying to add the following to htaccess file, so I don't have to use the CEON plugin.

redirect "http: //MySiteDOTcom/blue-jeans http: //MySiteDOTcom/index.php?main_page=index&cPath=9"

It sends me to the "not found page".
/index.php?main_page=page_not_found

Is there a way to achieve this?

10 May 2014, 8:58 AM
#2
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: htaccess redirect

Kevin205:

I am trying to add the following to htaccess file, so I don't have to use the CEON plugin.

redirect "http: //MySiteDOTcom/blue-jeans http: //MySiteDOTcom/index.php?main_page=index&cPath=9"

It sends me to the "not found page".
/index.php?main_page=page_not_found

Is there a way to achieve this?

There's several ways of achieving this, and your example is just one of them (albeit, not correctly implemented).

The correct syntax using your method would be:
redirect 301 /blue-jeans http://somesiteDOTcom/index.php?main_page=index&cPath=9

The easiest way to add this kind of redirect though is to use the redirect tool from your cPanel (assuming you use cPanel). Doing it this way is just a matter of first navigating to the page you wish to end up on, and copying the URL.
Next you'll log into your cPanel and clicking on the 'redirects' link.
Select the domain (assuming you have more than one) and entering the URL you wish to redirect (/blue-jeans), then finally pasting the URL previously copied into the 'redirects to' box.

That's it. Job done. No direct file edits needed. (The Cpanel redirect module takes the info provided and writes to the .htaccess file for you, ensuring it that the syntax is correct as it does so).

Cheers
RodG

10 May 2014, 9:34 PM
#3
kevin205 avatar

kevin205

Totally Zenned

Join Date:
Dec 2012
Posts:
607
Plugin Contributions:
0

Re: htaccess redirect

Thank you for the reply Rod. The host uses cPanel. But for testing purposes I am placing them directly at root's htaccess file.

The following re-directs fine now
redirect 301 /blue-jeans http://somesiteDOTcom/index.php?main_page=index&cPath=9

But when I add www, It sends it to the "not found page"
redirect 301 /blue-jeans http://**www.**somesiteDOTcom/index.php?main_page=index&cPath=9

I should mention that site has the following in the <head> area

<base href="http://somesiteDOTcom/" /> <link rel="canonical" href="http://somesiteDOTcom/" />

Frankly, I do not know what the above does? Any recommendations?

10 May 2014, 10:11 PM
#4
kevin205 avatar

kevin205

Totally Zenned

Join Date:
Dec 2012
Posts:
607
Plugin Contributions:
0

Re: htaccess redirect

Rod - I should have listened to your first suggestion! Through cPanel. Every works fine now.
It looks as follow:

RewriteCond %{HTTP_HOST} ^somesite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.somesite.com$
RewriteRule ^blue-jeans$ "http://somesite.com/index.php?main_page=index&cPath=9" [R=301,L,NE]

Thank you.