Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

redirecting site to subdomain after new wordpress installation - urgent help please


NigelW

Recommended Posts

The company I work for decided that they wanted to have a new WordPress site, to run alongside the osc site, and commissioned someone to built the site for us.

It was decided that they wanted the new site to sit in the main domain (say www.mysite.co.uk), and to move the store to a sub-domain (shop.mysite.co.uk), which points to a folder 'shop' in the 'public_html' folder of our site.

The local paths on the server would be 'home/mysite/public_html/' & 'home/mysite/public_html/shop/'

 

After a bit of head scratching I managed to configure the store for the sub-domain, however I have not worked out how to create the permanent redirects in the root .htaccess file for the main pages of the store (product_info.php probably the most important one for Google etc.) except 'index.php' which is used by WordPress

 

My knowledge of .htaccess is very limited, this is the code generated by WordPress for the permalinks

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

 

 

What I need to do is specify that if the browser requests a page:

www.mysite.co.uk/product_info.php{params}

it gets redirected to:

shop.mysite.co.uk/product_info.php{params}

 

 

I have tried a few things with no success, everytime I click on a link in Google, to the old location, it always ends up with a 'Page not found' page in the WordPress site.

 

Any suggestions ?

Link to comment
Share on other sites

I think there must have been an error during the setup of the osCommerce and the WordPress.

 

I've set up a WORKING example for you to look at of WordPress installed in root and osCommerce in a Subdomain. They both default installs - WP3.6.1 and osCommerce 2.3.3.3

 

You can view it here: breadon.com

 

I made no changes to WordPress .htaccess or osCommerce config files

"The doorstep to the temple of wisdom is a knowledge of our own ignorance."

Link to comment
Share on other sites

The problem is that wordpress index.php use the main domain. If you would like to do something by this way you could use header() redirection in WP index.php when oscommerce files are called in the server request filename.

 

Or there are several redirection plugins for WP.

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Link to comment
Share on other sites

Ok, I might have given the wrong importance about WordPress, the store and WP are working fine (some minor issues - but nothing to worry about).

 

What I have done is basically move the store to a new URL, and I want to create a set of redirect rules to point people/Google/Yahoo/etc to the new URL.

 

The snag is that the new URL is a sub-domain of the old URL, and is on the same server

 

Basically it's like using:

redirect 301 /product_info.php http://shop.mysite.co.uk/product_info.php

 

except that this won't work because store.mysite.co.uk is in a sub-directory of www.mysite.co.uk, and ends up with a infinite redirect loop, so I need to find another way of writing the redirects, whilst maintaining the WordPress generated code.

 

I think I need something like a set of RewriteRules & RewriteConditions to make this work.

 

I am not too worried about the index.php page - there is a link to the store on that page - I am mostly concerned about the links to products (i.e. product_info.php pages)

 

(but thank you for your input so far)

Link to comment
Share on other sites

Using a wildcard redirect will look like this (this is based on the same url - breadon.com - I posted above

 

RewriteEngine on
RewriteCond %{HTTP_HOST} ^breadon\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.breadon\.com$
RewriteRule ^product_info\.php\/?(.*)$ "http\:\/\/shop\.breadon\.com\/product_info\.php\?products_id\=1$1" [R=301,L]

 

Now what the above will do it will take any url that that has

 

breadon.com/product_info.php?products_id=X and it will redirect it to

 

shop.breadon.com/product_info.php?products_id=1

 

What you need to do is perhaps try and find out what can be done in order to get that last part of the rule also to change the products_id to the id you want it to be.

 

Here is a good article explaining this: randomtype.ca/blog/the-wordpress-htaccess-file-explained/

 

And if I understand it correctly - it would have something to do with adding this - somewhere to the .htaccess

 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

 

Sorry I cant be of anymore help - this is as close to it as I'll get for now - but I'm def going to make an effort to get to find out how it's done exactly.

 

For your site it would prob look something like this and of course you'll need to find out how and where you add the %{REQUEST_FILENAME} into the code below

 

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.co.uk$
RewriteRule ^product_info\.php\/?(.*)$ "http\:\/\/sub.domain\.co.uk\/product_info\.php\?products_id\=1$1" [R=301,L]

"The doorstep to the temple of wisdom is a knowledge of our own ignorance."

Link to comment
Share on other sites

Using a wildcard redirect will look like this (this is based on the same url - breadon.com - I posted above

 

RewriteEngine on
RewriteCond %{HTTP_HOST} ^breadon\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.breadon\.com$
RewriteRule ^product_info\.php\/?(.*)$ "http\:\/\/shop\.breadon\.com\/product_info\.php\?products_id\=1$1" [R=301,L]

 

Now what the above will do it will take any url that that has

 

breadon.com/product_info.php?products_id=X and it will redirect it to

 

shop.breadon.com/product_info.php?products_id=1

 

What you need to do is perhaps try and find out what can be done in order to get that last part of the rule also to change the products_id to the id you want it to be.

 

Here is a good article explaining this: randomtype.ca/blog/the-wordpress-htaccess-file-explained/

 

And if I understand it correctly - it would have something to do with adding this - somewhere to the .htaccess

 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

 

Sorry I cant be of anymore help - this is as close to it as I'll get for now - but I'm def going to make an effort to get to find out how it's done exactly.

 

For your site it would prob look something like this and of course you'll need to find out how and where you add the %{REQUEST_FILENAME} into the code below

 

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.co.uk$
RewriteRule ^product_info\.php\/?(.*)$ "http\:\/\/sub.domain\.co.uk\/product_info\.php\?products_id\=1$1" [R=301,L]

 

Perhaps its only a simple change - but this is the part that has to change - it mustnt point to the products_id=1 but to same as the filename that was requested

 

\?products_id\=1$1" [R=301,L]

"The doorstep to the temple of wisdom is a knowledge of our own ignorance."

Link to comment
Share on other sites

Ahh, that looks along the lines of what I have been looking at.

 

At least I am now getting redirected to the sub-domain instead of getting a 404 error page, but as you say it's trying to transfer the parameters along with the URL thats missing

 

But it's a step in the right direction :)

 

...

 

think I have solved it, I added the 3 lines into the mod_rewrite section with some changes to the last line:

 

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#
RewriteCond %{HTTP_HOST} ^mysite\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mysite\.co\.uk$
RewriteRule ^product_info\.php.*$ http://shop.mysite.co.uk/product_info.php?%{QUERY_STRING} [R=301,L]
#
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

 

Seems to be working - Thanks for you help you put me onto the right track

Link to comment
Share on other sites

They should have put the new WP installation into its own subdomain, or at least, a subdirectory. It's always asking for trouble to feed an application (osC) through another application's .htaccess (WP). Move WP down a level, move its .htaccess into the subdirectory, and use /.htaccess only to URL rewrite visitors to / down to the WP (plus any sitewide stuff like adding or removing www from the domain name).

Link to comment
Share on other sites

@ - I have another solution for you that works and you can test it on the domain I setup breadon.com

 

I have the following in my wordpress .htaccess

 

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?breadon\.com$ [NC]
RewriteRule ^product_info\.php$ http://shop.breadon.com/product_info.php [R=301,QSA,L]

 

for you - you would change it like this

 

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.co\.uk$ [NC]
RewriteRule ^product_info\.php$ http://shop.domain.co.uk/product_info.php [R=301,QSA,L]

 

This is working like a bomb :)

"The doorstep to the temple of wisdom is a knowledge of our own ignorance."

Link to comment
Share on other sites

@ - I have another solution for you that works and you can test it on the domain I setup breadon.com

 

I have the following in my wordpress .htaccess

 

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?breadon\.com$ [NC]
RewriteRule ^product_info\.php$ http://shop.breadon.com/product_info.php [R=301,QSA,L]

 

for you - you would change it like this

 

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.co\.uk$ [NC]
RewriteRule ^product_info\.php$ http://shop.domain.co.uk/product_info.php [R=301,QSA,L]

 

This is working like a bomb :)

 

The QSA flag automatically passes the query string back.

 

If you in fact need to change the ID too this is how you would do it:

 

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} products_id=([^&]+) [NC]
RewriteRule ^product_info\.php$ http://shop.domain.co.uk/product_info.php?products_id=1%1 [R=301,L]

 

you need to use %{QUERY_STRING} to get data from the query string.

 

with the above rule you will get the following

 

domain.com/product_info.php?products_id=4
domain.com/product_info.php?products_id=3
domain.com/product_info.php?products_id=2
domain.com/product_info.php?products_id=1

 

will be redirected to:

 

shop.domain.com/product_info.php?products_id=14
shop.domain.com/product_info.php?products_id=13
shop.domain.com/product_info.php?products_id=12
shop.domain.com/product_info.php?products_id=11

"The doorstep to the temple of wisdom is a knowledge of our own ignorance."

Link to comment
Share on other sites

Thanks everyone for your quick responses to my urgent plea for help :thumbsup:

 

My main objective is to permanently redirect existing search engine product results from the old url to the new, I noticed that some of the Google links contained manufacturers ids as well product ids, so maintaining the original structure of the query string would seem to be the most appropriate here.

 

Looking back over this thread I notice that I don't think I mentioned that the code generated by WP was because they were using the Permalinks option (this is what I was told - WP/permalinks are not something I have ever had to deal with before B) ), so I am keen not to interfere with it's functionality.

 

@@mommaroodles I really like this

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.co\.uk$ [NC]
RewriteRule ^product_info\.php$ http://shop.domain.co.uk/product_info.php [R=301,QSA,L]

it's more elegant than the code I ended up with.

 

incorporating this into the original WP like so:

# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.co\.uk$ [NC]
RewriteRule ^product_info\.php$ http://shop.domain.co.uk/product_info.php [R=301,QSA,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

but do I need 'Options +FollowSymLinks -MultiViews' ? I have tried it without this and it works fine. My concern is that it may cause issues with the WP permalinks

 

What does it do, and do i need it ?

Link to comment
Share on other sites

Let me hav

Thanks everyone for your quick responses to my urgent plea for help :thumbsup:

 

My main objective is to permanently redirect existing search engine product results from the old url to the new, I noticed that some of the Google links contained manufacturers ids as well product ids, so maintaining the original structure of the query string would seem to be the most appropriate here.

 

Looking back over this thread I notice that I don't think I mentioned that the code generated by WP was because they were using the Permalinks option (this is what I was told - WP/permalinks are not something I have ever had to deal with before B) ), so I am keen not to interfere with it's functionality.

 

@@mommaroodles I really like this

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.co\.uk$ [NC]
RewriteRule ^product_info\.php$ http://shop.domain.co.uk/product_info.php [R=301,QSA,L]

it's more elegant than the code I ended up with.

 

incorporating this into the original WP like so:

# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.co\.uk$ [NC]
RewriteRule ^product_info\.php$ http://shop.domain.co.uk/product_info.php [R=301,QSA,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

but do I need 'Options +FollowSymLinks -MultiViews' ? I have tried it without this and it works fine. My concern is that it may cause issues with the WP permalinks

 

What does it do, and do i need it ?

 

I'll have a look see and see what I come up with and will let you know. I dont have the permalinks set yet, but will do that - the right option to use for permalinks is the 'postname'

"The doorstep to the temple of wisdom is a knowledge of our own ignorance."

Link to comment
Share on other sites

The following line generally depends on the hosting environment and configuration at server level, so if it works just the same without it, I'd say remove it. The way your .htaccess is set now, is correct, though I am in favour of removing lines or commenting them out if you dont need it.

Options +FollowSymLinks -MultiViews

 

Here is a good source of info regarding the Options Directives, this will prob shed some more light on this subject for you.

 

httpd.apache.org/docs/2.0/mod/core.html#options

"The doorstep to the temple of wisdom is a knowledge of our own ignorance."

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...