HTACCESS Redirect For Ecommerce Site

Go To StackoverFlow.com

1

Could you please help to do a one off redirect in htaccess file from:

/something-something-something-something-c-2_19_70.html 

to this type of file that does not have the number -2_:

/something-something-something-something-c-19_70.html

I am sure there is a short code that will get applied to all url of that type

Thank you very much in advance

David

2012-04-04 21:54
by hsl


0

Put this code in your .htaccess under DOCUMENT_ROOT:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# redirect /something-something-something-something-c-2_19_70.html 
# to /something-something-something-something-c-19_70.html
RewriteRule ^(.*)2_(.*)$ $1$2 [L,NC,R]

# redirect /ethical-jewellery-silver-c-2_19.html to /silver-c-19.html
RewriteRule ^[^-]+-[^-]+-([^-]+-)([^-]+-)2_(.*)$ $1$2$3 [L,NC,R]
2012-04-05 14:59
by anubhava
Thank you but it did not work:- - hsl 2012-04-06 18:47
Thanks for being so helpful in explaining what didn't work :) btw this same rule is redirecting URI /something-something-something-something-c-2_19_70.html to /something-something-something-something-c-19_70.html in my testing. I suggest you to post your complete .htaccess in your question so I can investigate further - anubhava 2012-04-06 19:37
Hi, Thank you for your response - hsl 2012-04-07 20:36
I need to redirect this url: http://www.oriajewellery.co.uk/ethical-jewellery-silver-c-2_19.htm - hsl 2012-04-07 20:37
to this url: http://www.oriajewellery.co.uk/silver-c-19.htm - hsl 2012-04-07 20:37
both have the same content and need to be consolidated to get rid of duplicate content. The urls are dynamically generated but do not have an id. All the examples on the web do not seem to work. Any ideas how to make it work? Thank yo - hsl 2012-04-07 20:40
As per your question you wanted to redirect /something-something-something-something-c-2_19_70.html to /something-something-something-something-c-19_70.html but your comment is saying a different thing. Anyway pls check my edited answer as per your comment - anubhava 2012-04-08 06:05
Hi, Just tried and it did not work. Maybe there is something in the file that overwrites it? Do you have an email address so I could send you the htaccess file code? It does not fit here. Thank you very much for your help!:- - hsl 2012-04-09 12:27
Howsoever big it is, pls post your .htaccess here. The idea behind SO is to get your answers on SO itself by providing full details of your problem. That way other readers facing similar problems can also benefit - anubhava 2012-04-09 12:31
Ads