Forums / Basic Configuration / Directory Change Worked! Now I need a Redirect

Directory Change Worked! Now I need a Redirect

Views: 830

Results 1 to 7 of 7
31 Jul 2014, 12:01 AM
#1
phil_soth avatar

phil_soth

Zen Follower

Join Date:
Sep 2013
Location:
Warren, Oregon
Posts:
117
Plugin Contributions:
0

Directory Change Worked! Now I need a Redirect

Thanks to the sage advice to my question in thread 214069 above (Please Review My Directory Change Plan), I now have an operational installation under my root directory. I did it by copying - not moving -the contents of .../catalog/... to public_html. Made the changes in both configure.php files and everything works !

Now I would like to Redirect any inquiries from https://www.heirloomstocherish.com/catalog to https://www.heirloomstocherish.com. Do I add some code to a preexisting .htaccess file or do I create a new one? If I create a new one, where do I put it?

As of right now I have two functional installations, and desperately want to get down to only one, as the longer this goes the more the two installs will diverge with customer activity!

Thanks,
Phil

31 Jul 2014, 1:47 AM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Directory Change Worked! Now I need a Redirect

Phil Soth:

Thanks to the sage advice to my question in thread 214069 above (Please Review My Directory Change Plan), I now have an operational installation under my root directory. I did it by copying - not moving -the contents of .../catalog/... to public_html. Made the changes in both configure.php files and everything works !

Now I would like to Redirect any inquiries from https://www.heirloomstocherish.com/catalog to https://www.heirloomstocherish.com. Do I add some code to a preexisting .htaccess file or do I create a new one? If I create a new one, where do I put it?

As of right now I have two functional installations, and desperately want to get down to only one, as the longer this goes the more the two installs will diverge with customer activity!

Thanks,
Phil

You would modify (if available) the .htaccess in your public_html directory. (If one does not exist, then you would create it). You can't have two .htaccess files in the same directory, and eventually you will want to remove the old one. You could also somewhat fool the system I think by setting the sub-directories includes/configure.php file to point at all things in your root directory, but yes you will want to redirect the subdirectory to your root directory and include the appropriate code to indicate a permanent move.

The other thing is that if both stores are pointing to the same database, then the only real divergence would occur when adding products as the images may get saved to the "wrong" directory. But then again if all things point to the root directory that shouldn't be an issue either. So then the divergence would occur on updating files with say new plugins...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

31 Jul 2014, 1:54 AM
#3
phil_soth avatar

phil_soth

Zen Follower

Join Date:
Sep 2013
Location:
Warren, Oregon
Posts:
117
Plugin Contributions:
0

Re: Directory Change Worked! Now I need a Redirect

I have changed code in the root .htaccess file as follows:

Redirect 301 http://mystore/catalog/index.php http://mystore/index.php

but that doesn't seem to work. Did I code it wrong?

31 Jul 2014, 2:03 AM
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Directory Change Worked! Now I need a Redirect

Phil Soth:

I have changed code in the root .htaccess file as follows:

Redirect 301 http://mystore/catalog/index.php http://mystore/index.php

but that doesn't seem to work. Did I code it wrong?

Yes, that is wrong.

I usually have to "pull out the books" to work .htaccess rewrites, because they are one thing where you just set it and forget it until something new comes along.

The jest is this: need to turn on the rewrite engine I think it is, need to review the conditions being sent to the server, if the condition meets your subdirectory then it needs to remove the subdirectory from the path and continue processing with the remainder of the url, with the 301 and to possibly stop processing more rules.

I have an .htaccess in my store's root that includes all of the appropriate statements, but I don't have access to that at the moment.

The code that goes into the htaccess is something like another programming language. So it's not "bad" enough to have to know php, but there is also html, css, sql, javascript, and whatever language is needed to deal with htaccess work. :)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

31 Jul 2014, 2:39 AM
#5
phil_soth avatar

phil_soth

Zen Follower

Join Date:
Sep 2013
Location:
Warren, Oregon
Posts:
117
Plugin Contributions:
0

Re: Directory Change Worked! Now I need a Redirect

What if I were to change the index.php file itself under http://mystore/catalog to point at http://mystore the minute the index filed is opened? Looks like that's where the application starts...

Please advise

...and thanks for trying to help me!

Phil

31 Jul 2014, 3:57 AM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Directory Change Worked! Now I need a Redirect

Phil Soth:

I have changed code in the root .htaccess file
You said you "changed" something. What was it before?

Phil Soth:

Redirect 301 http://mystore/catalog/index.php http://mystore/index.php

but that doesn't seem to work. Did I code it wrong?
If you're using just a simple "Redirect 301", then the following MIGHT work:

Redirect 301 /catalog/index.php http://mystore/index.php
Redirect 301 /catalog/ http://mystore/

(The second line is to catch other things like ipn_main_handler.php and the other .html files etc in the root, which if you forgot to update elsewhere might cause unexpected problems if you didn't have this catchall.)

You could possibly write something more sophisticated using RewriteCond and RewriteRule directives with Regex patterns, but those may not be necessary. And I always have to pull out the books to figure those out, so I'm not gonna try to write one here off the top of my head.
There are other folks who claim to be SEO gurus that ought to be experts on these things, so ask them and make them work for their money.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

31 Jul 2014, 4:41 AM
#7
phil_soth avatar

phil_soth

Zen Follower

Join Date:
Sep 2013
Location:
Warren, Oregon
Posts:
117
Plugin Contributions:
0

Re: Directory Change Worked! Now I need a Redirect

DrByte, you are genius! That worked exactly how I wanted it to!

Couple minor issues, but they are easily solvable....I can't log in to my catalog/Admin, but why would I want to...after all, I'm the only one needing access to it and I can get there through my root admin. The other issue is the CC and SSL icons don't display because they were coded in the myshop/common/tpl_header.php which of course is no longer referenced with the Redirect - easy to change!

The pre-change .htaccess coded I was referring to was what I used when my Zen Cart was still under development and was slowly replacing the Front Page application (guffaws, do I hear?)

Tha code redirected a customer from my FP site to my ZC site, and worked fine. Now it's time to move forward..

The code was

-FrontPage-

Redirect 301 http://myshop/catalog/index.php /index.htp

Again, thanks to both mc12345678 and DrByte for your support and interest in my issue!
Phil