[osCommerce] Rewrite rule for custom page not redirecting

Custom URLs and redirections.

[osCommerce] Rewrite rule for custom page not redirecting

Postby shotputty » Wed May 12, 2010 4:04 am

This is a working (but also known) page in OScommerce that works perfectly by this rule in .htaccess:

Code: Select all
#contact_us.php - contact us
RewriteRule ^([a-z]{2})/contact-us$ contact_us.php?language=$1 [L,QSA]


--> mydomain.com/nl/contact-us -> perfect!

I've added the same rule for a custom page:

Code: Select all
#all_products.php - all products
RewriteRule ^([a-z]{2})/all-products$ all_products.php?language=$1 [L,QSA]


The page works, but it does not redirect.

--> mydomain.com/all_products.php

Does not redirect to: mydomain.com/nl/all-products (which does work after the added line in .htaccess)

Also, it does not change the links, whereas the "links" from anywhere on the site for contact_us.php show up as wanted, like: mydomain.com/de/contact-us or mydomain.com/uk/contact-us depending on which language you're looking at the site. Cool feature by the way 8-)


What am I missing to get this functionality for non-standard OScommerce pages?
shotputty
Follower
 
Posts: 45
Joined: Tue May 11, 2010 2:28 pm

Re: [osCommerce] Rewrite rule for custom page not redirectin

Postby ~J~ » Wed May 12, 2010 1:22 pm

shotputty wrote:The page works, but it does not redirect.

--> mydomain.com/all_products.php

Does not redirect to: mydomain.com/nl/all-products (which does work after the added line in .htaccess)


To redirect such pages, you will need to also add a redirect rule to .htaccess file.
~J~

Magic SEO URLs got new Home at InveoStore.com and are now available for
osCommerce, CRE Loaded, Zen Cart, PrestaShop, OpenCart, CubeCart, phpBB and phpBB3!
~J~
Magic SEO URL Founder
 
Posts: 1017
Joined: Sat Feb 02, 2008 11:07 am
Location: Prague, Central Europe

Re: [osCommerce] Rewrite rule for custom page not redirectin

Postby shotputty » Wed May 12, 2010 10:56 pm

How would such a rule look like? As the site is muti language it needs to be variable.
shotputty
Follower
 
Posts: 45
Joined: Tue May 11, 2010 2:28 pm

Re: [osCommerce] Rewrite rule for custom page not redirectin

Postby shotputty » Thu May 13, 2010 10:11 am

I thought of this (but it doesn't work)

Code: Select all
redirect 301 /all_products.php?language=$1 ^([a-z]{2})/all-products$ [L,QSA]


It's like abracadabra to me :roll:
shotputty
Follower
 
Posts: 45
Joined: Tue May 11, 2010 2:28 pm

Re: [osCommerce] Rewrite rule for custom page not redirectin

Postby ~J~ » Thu May 13, 2010 11:19 am

It has to be something like:

Code: Select all
RewriteCond %{QUERY_STRING} ^language=([a-z]{2})$
RewriteRule ^all_products.php$ ^%1/all-products$ [L,R=301]
~J~

Magic SEO URLs got new Home at InveoStore.com and are now available for
osCommerce, CRE Loaded, Zen Cart, PrestaShop, OpenCart, CubeCart, phpBB and phpBB3!
~J~
Magic SEO URL Founder
 
Posts: 1017
Joined: Sat Feb 02, 2008 11:07 am
Location: Prague, Central Europe

Re: [osCommerce] Rewrite rule for custom page not redirectin

Postby shotputty » Thu May 13, 2010 12:35 pm

OK I have these lines of code in .htaccess now, in this order:

Code: Select all
#all_products.php - all products
RewriteRule ^([a-z]{2})/all-products$ all_products.php?language=$1 [L,QSA]
RewriteCond %{QUERY_STRING} ^language=([a-z]{2})$
RewriteRule ^all_products.php$ ^%1/all-products$ [L,R=301]


When I access the page it still says mydomain.com/all_products.php and when I change language to german for instance on that page it gives me a 404 not found.
In the address bar it now says: mydomain.com/%5ede/all-products$?language=de

Do I need to write the code in this order or is it something else?
shotputty
Follower
 
Posts: 45
Joined: Tue May 11, 2010 2:28 pm

Re: [osCommerce] Rewrite rule for custom page not redirectin

Postby ~J~ » Thu May 13, 2010 12:37 pm

It wasn't correct.

Code: Select all
RewriteCond %{QUERY_STRING} ^language=([a-z]{2})$
RewriteRule ^all_products.php$ %1/all-products? [L,R=301]
~J~

Magic SEO URLs got new Home at InveoStore.com and are now available for
osCommerce, CRE Loaded, Zen Cart, PrestaShop, OpenCart, CubeCart, phpBB and phpBB3!
~J~
Magic SEO URL Founder
 
Posts: 1017
Joined: Sat Feb 02, 2008 11:07 am
Location: Prague, Central Europe

Re: [osCommerce] Rewrite rule for custom page not redirectin

Postby shotputty » Thu May 13, 2010 11:17 pm

I can't get it to work in all different orders..

I tried:

Code: Select all
RewriteCond %{QUERY_STRING} ^language=([a-z]{2})$
RewriteRule ^([a-z]{2})/all-products$ all_products.php?language=$1 [L,QSA]
RewriteRule ^all_products.php$ %1/all-products? [L,R=301]


and

Code: Select all
RewriteRule ^([a-z]{2})/all-products$ all_products.php?language=$1 [L,QSA]
RewriteCond %{QUERY_STRING} ^language=([a-z]{2})$
RewriteRule ^all_products.php$ %1/all-products? [L,R=301]


and

Code: Select all
RewriteCond %{QUERY_STRING} ^language=([a-z]{2})$
RewriteRule ^all_products.php$ %1/all-products? [L,R=301]
RewriteRule ^([a-z]{2})/all-products$ all_products.php?language=$1 [L,QSA]


and

Code: Select all
RewriteCond %{QUERY_STRING} ^language=([a-z]{2})$
RewriteRule ^all_products.php$ %1/all-products? [L,R=301]


This last one gives me correct links to mydomain/language/all-products when a language is selected (but no redirect when being on the page initially) but then they don't work :)
By the way, I write the rules on the bottom of .htaccess, should that matter?

ps: I have 12 pages like this one.
shotputty
Follower
 
Posts: 45
Joined: Tue May 11, 2010 2:28 pm

Re: [osCommerce] Rewrite rule for custom page not redirectin

Postby shotputty » Sat May 15, 2010 1:38 am

I these 2 rules can be merged into 1 rule I think it should work (with the RewriteCond above it ofcourse):

Code: Select all
RewriteRule ^all_products.php$ %1/all-products? [L,R=301]
RewriteRule ^([a-z]{2})/all-products$ all_products.php?language=$1 [L,QSA]


Is that possible or is it no problem to have 2 rules for the same file?
shotputty
Follower
 
Posts: 45
Joined: Tue May 11, 2010 2:28 pm

Re: [osCommerce] Rewrite rule for custom page not redirectin

Postby shotputty » Thu May 20, 2010 1:21 am

Is this too difficult? What are the options for all the OScommerce users who have a non standard static php page added in their shop?

Can't there be a uniform solution, maybe add pagenames in the .ini file in the future? :P

Or can these pages be added in the magic-seo-rul.php file on request?
shotputty
Follower
 
Posts: 45
Joined: Tue May 11, 2010 2:28 pm

Next

Return to Custom Rewrite Rules

Who is online

Users browsing this forum: No registered users and 2 guests

cron