homepage Welcome to WebmasterWorld Guest from 54.204.215.209
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Complex URL rewrite - assistance kindly requested
davidh




msg:4600173
 12:04 am on Aug 8, 2013 (gmt 0)

I'd be very grateful for some help with the following issue. I have checked extensively and been unable to find a solution elsewhere.

Where "XX" can be any single digit or double digit number from 1 through 99, I would like Apache to redirect/rewrite the following pattern:

http://mysite.com/term1/XX/some-title

to

http://mysite.com/term1/some-title

The objective here would be to strip out the XX, while preserving what is on either side of it.

"Term 1" could be one of five different, set alphabetical expressions; some title could be almost any number letter combination.

Many thanks for any advice or insights.

 

lucy24




msg:4600184
 12:43 am on Aug 8, 2013 (gmt 0)

That seems pretty straightforward. Capture A, skip B, capture C, redirect to AC. So there must be some complication that you haven't mentioned. Let's see your best effort to date. In what way doesn't it work?

:: looking vaguely around for "Why we make you do it yourself" boilerplate ::

phranque




msg:4600196
 2:29 am on Aug 8, 2013 (gmt 0)

welcome to WebmasterWorld, davidh!


show us what you tried so we can help you fix it.

g1smd




msg:4600222
 6:44 am on Aug 8, 2013 (gmt 0)

A related question is:

"When a user requests
http://mysite.com/term1/some-title is the site already set up in such a way that the correct content is shown?"
davidh




msg:4600898
 3:09 pm on Aug 10, 2013 (gmt 0)

Hello, apologies for the delay, was traveling. Thank you for your responses.

lucy24 and phranque: I have been unable to construct a redirect or rewrite that would provide the desired results. The examples that I have seen available on the internet do not address my specific need and those that I have tried to adapt have failed, and I regret to report that I did not retain the code. Mind you, I realize that my initial search cannot possibly have been exhaustive, and if, based on your own expertise, you would be so kind as to point me in the right direction, I will be glad to give it a another go and report back.

g1smd: Yes, that is correct, the site is already set up that way, thank you for asking and my apologies for failing to mention that.

Dideved




msg:4600939
 7:52 pm on Aug 10, 2013 (gmt 0)

I googled for "apache redirect/rewrite any single digit or double digit number", and the first 2-3 results are good intros, which include some examples very close to what you're after.

penders




msg:4601298
 2:49 pm on Aug 12, 2013 (gmt 0)

I would like Apache to redirect/rewrite...


Which would you like to do... redirect or rewrite? I assume redirect...

Something like (in .htaccess):

RewriteEngine On
RewriteRule ^(term1|term2|term3|term4|term5)/\d{1,2}/(.+)$ /$1/$2 [R=301,L]


?

(As lucy24 says... Capture A, skip B, capture C, redirect to AC.)

davidh




msg:4601319
 4:16 pm on Aug 12, 2013 (gmt 0)

Dear penders: To have delivered to me, in such a kind and understated manner, a seemingly simple line of code that works perfectly on the first try and which, as a consequence, has just made my online existence easier by orders of magnitude, is a gift for which I cannot adequately express my thanks. Many thanks, david

[edited by: phranque at 6:09 pm (utc) on Aug 13, 2013]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved