Forum Moderators: phranque

Message Too Old, No Replies

Stripping Redirect

         

webcitz

5:28 pm on Jun 1, 2012 (gmt 0)

10+ Year Member



Hello,

I have thousands of URLs that all have a similar feature that I would like to utilize as a stripping type of regular expression, if possible. Here is an example of one of the bad URLs:

Bad URL Example: http://www.example.com/folder1/folder2/folder3/url-name.html?var1=A&var2=B

What I would like to do is setup a single redirect that would simply take the person from that bad URL straight to the following:


Desired Result: http://www.example.com/folder1/folder2.html

In my real-life situation, folder2 isn't really a folder but a category name for products. Additionally, folder3 isn't really a folder either, but instead a line of text that says "shopby" which breaks out filterable attributes both in redirects and url parameters thereafter.

g1smd

6:26 pm on Jun 1, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It's a couple of lines of code utilising a RewriteCond and a RewriteRule.

Lucy posts a boilerplate explaining how query string processing works, at least several times each week.

Check that out and post your best shot at the necessary code as per the forum charter.

lucy24

7:25 pm on Jun 1, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



:: insert boilerplate about Going Extensionless (g1 meant to say something but was in a hurry) ::