Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

.HTACCESS Rewrite Rule 301

Posted on 2013-05-13
3
Medium Priority
?
422 Views
Last Modified: 2016-03-02
Hi,

I have various hundred URL's that have been indexed in google and I need to resolve them and redirect them. The pattern is like this:

www.mydomain.com/en/decor/somefolder-1/somepage-1.html?p=4
www.mydomain.com/it/somepage-1.html
www.mydomain.com/es/somefolder/anotherfolder-1/somepage.html

The CMS I use, Magento, has a rewrite module that fails sometimes and adds -1 to folders and to .html files.

As you can see, I would need a rewrite rule that would take off the -1 for the folders and the -1 just before the .html for pages.

I would need it to 301 the incoming requests based on above and rewrite them to:

www.mydomain.com/en/decor/somefolder/somepage.html?p=4
www.mydomain.com/it/somepage.html
www.mydomain.com/es/somefolder/anotherfolder/somepage.html

Your help is greatly appreciated.

thanks!
0
Comment
Question by:intangiblemedia
  • 2
3 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 1500 total points
ID: 39163624
RewriteRule %{REQUEST_URI} ^(.*)-[0-9]*/(.*\.html) $1/$2 [QSA]
RewriteRule %{REQUEST_URI} ^(.*)-[0-9]*(\.html) $1$2 [QSA]
0
 

Author Comment

by:intangiblemedia
ID: 39163838
thanks for your answer - I tried them, but both give me http 500 errors and site doesnt load...
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 39163859
can you please post the corresponding entry from your error-log
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question