Zen Cart Logo
Forums / General Questions / How to redirect a product url to sub.domain?

How to redirect a product url to sub.domain?

Views: 2,063

Results 1 to 16 of 16
28 May 2016, 11:16 PM
#1
hara avatar

hara

Zen Follower

Join Date:
Sep 2008
Posts:
397
Plugin Contributions:
0

How to redirect a product url to sub.domain?

Hello Sir,

Since this version causes some products descriptions not editable, and try to keep current good traffic on the web, I decided to redirect to new site in subdomain.

How can I redirect a product from http:// url to a new url in https://sub.domain?

Please help. Thanks in advance!

29 May 2016, 1:24 AM
#2
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: How to redirect a product url to sub.domain?

Why not do an upgrade of your software keeping all your existing links, ranking, etc...?

https://www.zen-cart.com/entry.php?3-How-do-I-rebuild-my-site-on-the-new-version-instead-of-upgrading

If you are going to go the path of redirecting all of your traffic to a sub-domain then you would need an htaccess (.htaccess) file that detects someone trying to access your site using www dot yourdomain dot com or the same without www and redirect to your subdomain. Seems kind of pointless though to redirect if you've already got a site that is working in the current environment. All that is needed is to move that site to your old location: http://www.zen-cart.com/content.php?160-i-have-installed-zen-cart-to-a-directory-how-do-i-rename-or-move-that-directory

29 May 2016, 4:24 AM
#3
hara avatar

hara

Zen Follower

Join Date:
Sep 2008
Posts:
397
Plugin Contributions:
0

Re: How to redirect a product url to sub.domain?

mc12345678:

Why not do an upgrade of your software keeping all your existing links, ranking, etc...?

https://www.zen-cart.com/entry.php?3-How-do-I-rebuild-my-site-on-the-new-version-instead-of-upgrading

If you are going to go the path of redirecting all of your traffic to a sub-domain then you would need an htaccess (.htaccess) file that detects someone trying to access your site using www dot yourdomain dot com or the same without www and redirect to your subdomain. Seems kind of pointless though to redirect if you've already got a site that is working in the current environment. All that is needed is to move that site to your old location: http://www.zen-cart.com/content.php?160-i-have-installed-zen-cart-to-a-directory-how-do-i-rename-or-move-that-directory

Thank you MC12345678,

Upgrade from v1.39h to v1.5 is a big step for me, not only too much work but also there are many potential problem with my current template and modules concern. So I decided rebuild my site on a latest version.

29 May 2016, 4:47 AM
#4
hara avatar

hara

Zen Follower

Join Date:
Sep 2008
Posts:
397
Plugin Contributions:
0

Re: How to redirect a product url to sub.domain?

Hello Sirs,

Is it possible, simply redirect product link to sub-domain product by using these two elements under product settings on old site?
Products URL: to new site url
URI Mapping:

Please advise. Thanks in advance!

29 May 2016, 5:11 AM
#5
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: How to redirect a product url to sub.domain?

hara:

Thank you MC12345678,

Upgrade from v1.39h to v1.5 is a big step for me, not only too much work but also there are many potential problem with my current template and modules concern. So I decided rebuild my site on a latest version.

If you in fact rebuilt using the latest version, then you basically have upgraded your site. The two documents linked above would allow you to have your guests continue to access your site the way they used to but using the latest software.

When you said you rebuilt, did you export the database from your old site and import it into your new site or did you manually enter everything?

The rewrite path(es) you suggested complicate things well beyond what you need to complete what you have begun.

29 May 2016, 5:29 AM
#6
hara avatar

hara

Zen Follower

Join Date:
Sep 2008
Posts:
397
Plugin Contributions:
0

Re: How to redirect a product url to sub.domain?

I manually enter everything. Did not export to New database.

Thanks!

29 May 2016, 2:25 PM
#7
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: How to redirect a product url to sub.domain?

The solution that I would offer to maintain all things as they were under the new program code would be to create a third location for your site.

This would include creating another database, as well as copying all of the files from your most recent rebuild. Then after the files are able to manage the third store, replace contents of the third database with your database from the original store, upload zc_install from the ZC version associated with the files, perform a database only upgrade. Check operation. If that works then would basically repeat that portion of the process on your original store (a little more to it as want to keep a copy of your old files but want to have only the files from your most recent version in that location). If there is any additional database code to be applied to the third database then take note of those actions and again replace the original store files and upgrade the database.

Otherwise the "easy" way at which point all existing links/references would be lost would be to simply move all of the old files out of the way, place the new files in the directory using the second link that was provided above in post #2. Trying to remap all of the product from an old uri to a new one one at a time is a recipe for disaster and why the upgrade process suggested (at least from the database standpoint) is suggested/provided.

29 May 2016, 3:21 PM
#8
hara avatar

hara

Zen Follower

Join Date:
Sep 2008
Posts:
397
Plugin Contributions:
0

Re: How to redirect a product url to sub.domain?

mc12345678:

The solution that I would offer to maintain all things as they were under the new program code would be to create a third location for your site.

This would include creating another database, as well as copying all of the files from your most recent rebuild. Then after the files are able to manage the third store, replace contents of the third database with your database from the original store, upload zc_install from the ZC version associated with the files, perform a database only upgrade. Check operation. If that works then would basically repeat that portion of the process on your original store (a little more to it as want to keep a copy of your old files but want to have only the files from your most recent version in that location). If there is any additional database code to be applied to the third database then take note of those actions and again replace the original store files and upgrade the database.

Otherwise the "easy" way at which point all existing links/references would be lost would be to simply move all of the old files out of the way, place the new files in the directory using the second link that was provided above in post #2. Trying to remap all of the product from an old uri to a new one one at a time is a recipe for disaster and why the upgrade process suggested (at least from the database standpoint) is suggested/provided.

Hi mc12345678,

Thank you so much for the knowledge I learned.

For temporary solution, use .htaccess 301 redirect will lose original traffic and ranking?
Will Redirect by using SEO url causes any problem?

Thanks in advance!

29 May 2016, 5:26 PM
#9
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: How to redirect a product url to sub.domain?

hara:

Hi mc12345678,

Thank you so much for the knowledge I learned.

For temporary solution, use .htaccess 301 redirect will lose original traffic and ranking?
Will Redirect by using SEO url causes any problem?

Thanks in advance!
301 is a permanent redirect. If want to temporarily redirect would want to use a 302.

A majority of such uri rewriters are not intended to redirect the way that is being described. It can still be possible, but solving this issue using those methods will use more energy now (and in the future) to solve something that can be corrected now and for the future.

If your site currently uses some form of uri rewriting then depending on which one has been used and what general information is out there as to what the impact of replacing the current store with the new manually entered database would be, but if you used your existing database to upgrade it, then the uris to the products should remain the same.

29 May 2016, 7:35 PM
#10
hara avatar

hara

Zen Follower

Join Date:
Sep 2008
Posts:
397
Plugin Contributions:
0

Re: How to redirect a product url to sub.domain?

I'm testing .htaccess redirect by adding this code:
Redirect 301 /s-e-o-page http://www.yoursite.com/s-e-o-newpage

But no page found in result because I can see that old site's fold added to new site's path as:
http://www.yoursite.com/abcde/s-e-o-newpage

Please advise. Thanks in advance!

29 May 2016, 9:03 PM
#11
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: How to redirect a product url to sub.domain?

htaccess files are a program of their own, to support a solution need to see what it is you have. Please post your htaccess file but obscure the admin directory if it is included. Also, before posting it please press the # button in the menu bar of the message box when you are replying.

30 May 2016, 5:48 AM
#12
hara avatar

hara

Zen Follower

Join Date:
Sep 2008
Posts:
397
Plugin Contributions:
0

Re: How to redirect a product url to sub.domain?

RewriteEngine On

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(demoshop|failed_auth\.html).*$ [NC]
RewriteRule . - [L]
</IfModule> 

# Don't rewrite any URIs ending with a file extension (ending with .[xxxxx])
RewriteCond %{REQUEST_URI} !\.[a-zA-Z]{2,5}$ [NC]
# Don't rewrite admin directory
RewriteCond %{REQUEST_URI} !^/hided
# Don't rewrite editors directory
RewriteCond %{REQUEST_URI} !^/editors [NC]
# Don't rewrite cPanel directories
RewriteCond %{REQUEST_URI} !/cpanel [NC]
RewriteCond %{REQUEST_URI} !/frontend [NC]
# Handle all other URIs using Zen Cart (index.php)
RewriteRule .* index.php?%{QUERY_STRING} [L]

Redirect 301 /s-e-o-page https://www.sub.mysite.com/s-e-o-newpage 

Please help. Thanks in advance!

30 May 2016, 7:40 AM
#13
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: How to redirect a product url to sub.domain?

You've got a lot going on. With CEON uri installed and this redirect to your "disabled" product it almost looks like the new 301 redirect should be above the other rewriteRules but also looks like might want to either stop rewriting once s-e-o-page is found.

Thing is, now that you have been working to use your sub-domain your rewriteCond statements likely don't look right for your sub-domain condition. Have you gone to the installation check to see what .htaccess rules it recommends at this point? Normally the rewriteConds should include the subdirectory in which the store is installed. Those don't appear here...

What does the s-e-o-page represent? Is that to which your site goes when a page is not found?

BTW, I won't be able to help for much longer this go round because of time differential, etc...

31 May 2016, 3:47 AM
#14
hara avatar

hara

Zen Follower

Join Date:
Sep 2008
Posts:
397
Plugin Contributions:
0

Re: How to redirect a product url to sub.domain?

mc12345678:

......................
What does the s-e-o-page represent? Is that to which your site goes when a page is not found?
...

No, s-e-o-page represent a old site page that using seo.
I'm trying to redirect to this page: https://www.sub.mysite.com/s-e-o-newpage
The problem now is, an unwanted folder added to new site page like https://www.sub.mysite.com/unwanted_folder/s-e-o-newpage. So get page not found in result.

As I understand, CEON uri module and rewriteCond cause the problem. It seems things are getting even more complicated. I will work more harder for it.

Thanks in advance!

31 May 2016, 10:31 AM
#15
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: How to redirect a product url to sub.domain?

hara:

No, s-e-o-page represent a old site page that using seo.
I'm trying to redirect to this page: https://www.sub.mysite.com/s-e-o-newpage
The problem now is, an unwanted folder added to new site page like https://www.sub.mysite.com/unwanted_folder/s-e-o-newpage. So get page not found in result.

As I understand, CEON uri module and rewriteCond cause the problem. It seems things are getting even more complicated. I will work more harder for it.

Thanks in advance!
Did you previously have something like CEON URI installed on your system?

If so, then yes by continuing down this path rather than doing the upgrade as previously suggested you have a lot of work ahead of you. Still not sure why you continue to make this ever harder, but here goes.

For every entry in your ceon_uri_mappings table, the active_status of your old URI must be made false (0). Then, for all of the entries other than the uri, two things need to happen, one a new entry with active_status of 1 needs to be made for all of the other matching data with the path to your sub-directory or sub-domain whichever is being used and that path needs to be based off of whatever you have for your HTTP_SERVER style info. This is because the ceon software, when it receives the request for that specific uri (that is no longer "correct") with the status marked as false, will look for an active uri that has all of the other matching information. It will then respond/report that the new uri is what you have entered above or that the product is not found.

Then you need to fill in the gaps that might exist such that you have an active uri for your product in your store.

So, one thing to note though is that you can not have the same uri as both active and inactive or two or more of either as that could cause unpredictable results.

Now, if the uri path is to be the same now as it was before, then you need to only update the other values to reflect the new data such as the products_id being something different now than it was before. But also would need to redirect a the request to go to your old site to now go to your sub-domain and that needs to be done before/above the existing CEON uri htaccess info and such that the request is allowed to continue down/forward (not use [L] on the end of the rewriterule) I would also suggest that the rewrite conditions include a check for the http_host to validate that in fact the request is being made against your new sub-domain and to apply those rules only against this sub-domain.

Like said, would have been much easier to setup a third version of the site using the files from the second site, import the database of the original site, update that database and then place your updated files from the second/third site where your primary site is and again update the database of the first site using the process discovered/identified in upgrading that same data in the third site. Then delete the second site and database and use the third site as a development site where you could try out new things before applying to your primary site. Of course add some protection like put it in maintenance mode so others shouldn't be able to access it...

31 May 2016, 11:45 PM
#16
hara avatar

hara

Zen Follower

Join Date:
Sep 2008
Posts:
397
Plugin Contributions:
0

Re: How to redirect a product url to sub.domain?

Thank you very much mc12345678.

I will take your expert suggestion to upgrade to latest version eventually.
At same time now, I will still take little time to figure it and test if redirect can be achieve. My site still live and product's description can not be updated (editor no longer working on PHP5.6 higher version), and some customers complaint reset password function doesn't work.

Could you advise which file for editing product's description? (I did it before but forgot now).

Thanks you again for your time.