Zen Cart Logo
Forums / General Questions / htaccess rewrite question

htaccess rewrite question

Locked

Views: 4,787

Results 1 to 13 of 13
This thread is locked. New replies are disabled.
5 Mar 2008, 4:45 AM
#1
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

htaccess rewrite question

I know this is way off topic but maybe someone can help me.

I want to redirect all traffic from an old domain to my zen cart. I have it working...partly. I've got:

RewriteRule (.*) http://customcreationsunltd.com/shop/$1 [R=301,L]

which does redirect. But the problem is this, accessing a specific page at the old url, say file.htm redirects to http://customcreationsunltd.com/shop/file.htm but that file does no exist so I get a 404 error.

How can I get the redirect to redirect all traffic to index.php?

Thank you!!

5 Mar 2008, 11:43 AM
#2
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: htaccess rewrite question

Instead of using 'RewriteRule' it would be better to use RedirectMatch.

RedirectMatch .* http://customcreationsunltd.com/shop/
Options -Includes -Indexes -ExecCGI

Put the above in the .htaccess file for the old Domain. At some point though, you should change your Registrar information for the old Domain to point to 'customcreationsunltd.com' as that is a better way to do permenant redirects of this type.

5 Mar 2008, 1:58 PM
#3
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Re: htaccess rewrite question

Website Rob:

Instead of using 'RewriteRule' it would be better to use RedirectMatch.

RedirectMatch .* http://customcreationsunltd.com/shop/
Options -Includes -Indexes -ExecCGI

Put the above in the .htaccess file for the old Domain. At some point though, you should change your Registrar information for the old Domain to point to 'customcreationsunltd.com' as that is a better way to do permenant redirects of this type.

I tried both options and I'm still getting the file name passing to the new url. I hadn't thought about the registrar. There is an option to 'pass directories' and I unchecked that and set forward type to standard. The other option is stealth. The url I'm trying to forard is ccui.net, if that helps at all.

5 Mar 2008, 3:27 PM
#4
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: htaccess rewrite question

You've created a bit of a problem for yourself as you're not sure where you want to redirect the old URLs to. Would take some fancy Rewrite code to redirect each individual product, from the old URL to the new.

Best just to redirect all old URLs to one page explaining about the update and what to do now; such as you've already done with your 404 page. If you don't want them going to your 404 page then create a new page (siteupdate.php or whatever format you want to use) then explain about the changes. This somewhat duplicates your statement on your 404 pages but at least it will cut down on errors showing in your Hosting Error logs.

You would need to change the .htaccess directive on the old site to:

RedirectMatch .* http://customcreationsunltd.com/shop/siteupdate.php
Options -Includes -Indexes -ExecCGI

Remember, you have a lot of indexed URLs at various sites and to break them needlessly does you no good. If not changing settings at your Registrar then you should use:

RewriteEngine ON
RewriteRule ^(.*)$ http://customcreationsunltd.com/shop/siteupdate.php$1 [R=301,L]

This will allow SEs to update themselves and no negative reaction to your site(s).

5 Mar 2008, 3:43 PM
#5
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Re: htaccess rewrite question

Website Rob:

RewriteEngine ON
RewriteRule ^(.*)$ http://customcreationsunltd.com/shop/siteupdate.php$1 [R=301,L]

This will allow SEs to update themselves and no negative reaction to your site(s).

The old sites get little traffic anymore and aren't really maintained. Thus the reasont to redirect tehm. I would like to use the 301 for just that reason but can't seem to get it to do that.

I put that in the htaccess file (I actually used index.php) but it won't load that page. It's still trying pulling the page name from the old url and returning a 404.

5 Mar 2008, 4:18 PM
#8
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: htaccess rewrite question

Time to be very specific. :wink:

.htaccess at old site

RewriteEngine ON
RewriteRule ^(.*)$ http://customcreationsunltd.com/$1 [R=301,L]

Send everybody no matter what page they try, to the new site.

.htaccess at new site

RewriteEngine On

Old Links Redirection - Permanent

RewriteRule http://ccui.net/.*%28.*) http://customcreationsunltd.com/shop/siteupdate.php

Send everybody no matter what page they were trying at the old site, to the new page.

5 Mar 2008, 5:02 PM
#9
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Re: htaccess rewrite question

I like being specific. But would you believe it doesn't work. This is the htaccess on the new site:

RewriteEngine On

Old Links Redirection - Permanent

RewriteRule http://ccui.net/.*%28.*) http://customcreationsunltd.com/shop/index.php

RewriteCond %{HTTP_HOST} ^https://www.customcreationsunltd.com
RewriteRule (.*) http://customcreationsunltd.com/$1 [R=301]

redirect 301 /first_holy_communion.shtml http://customcreationsunltd.com/first-holy-communion-invitations.shtml
redirect 301 /anniversary_invitations.shtml http://customcreationsunltd.com/anniversary-invitations.shtml

Is something in here getting in the way?

5 Mar 2008, 11:31 PM
#10
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: htaccess rewrite question

RewriteCond %{HTTP_HOST} ^https://www.customcreationsunltd.com
RewriteRule (.*) http://customcreationsunltd.com/$1 [R=301]

Don't understand why you are using the above but can see where it would cause problems.

Should be written as:

RewriteCond %{HTTP_HOST} ^www.customcreationsunltd.com(.)
RewriteRule ^(.
)$ http://customcreationsunltd.com/$1 [R=301,L]

.htaccess file for new site would then look like:

Options FollowSymLinks

RewriteEngine ON
RewriteCond %{HTTP_HOST} ^www.customcreationsunltd.com(.)
RewriteRule ^(.
)$ http://customcreationsunltd.com/$1 [R=301]

Old Links Redirection - Permanent

RewriteRule http://ccui.net/.*%28.*) http://customcreationsunltd.com/shop/siteupdate.php [R=301,L]

6 Mar 2008, 2:06 AM
#11
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Re: htaccess rewrite question

Website Rob:

RewriteCond %{HTTP_HOST} ^https://www.customcreationsunltd.com
RewriteRule (.*) http://customcreationsunltd.com/$1 [R=301]

Don't understand why you are using the above but can see where it would cause problems.

I was using that to redirect all traffic to https://www.customcreationsunltd.com to customcreationsunltd.com I did remove the L because I thought that told Apache it was the last rule.

But thanks so much for all your help. I've got it redirecting correctly now.

6 Mar 2008, 4:19 AM
#12
heimskr75 avatar

heimskr75

Zen Follower

Join Date:
Apr 2007
Posts:
106
Plugin Contributions:
3

Re: htaccess rewrite question

Just out curiosity why rewrite anything?
Have you tried just the plain old 301 redirect?
something like:
Redirect 301 http://www.xxxxxxxxxxxx.com/large.php http://www.xxxxxxxxxxxx.com/index.php?main_page=index&cPath=1_19
obviously keep everything on the same line. But this method worked fine for me when I switched from static pages to ZC.
just a thought.

6 Mar 2008, 4:38 AM
#13
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Re: htaccess rewrite question

heimskr75:

Just out curiosity why rewrite anything?
Have you tried just the plain old 301 redirect?
something like:
Redirect 301 http://www.xxxxxxxxxxxx.com/large.php http://www.xxxxxxxxxxxx.com/index.php?main_page=index&cPath=1_19
obviously keep everything on the same line. But this method worked fine for me when I switched from static pages to ZC.
just a thought.

Fair question. The old sites (and there are three of them) each have 200-300 pages (not Zen, straight html). I haven't really promoted them in few years and the traffic has dwindled along with the orders. They still get traffic, so I don't want to lose it but it doesn't justify the time to create some 200 301 redirects.