Forum Moderators: phranque

Message Too Old, No Replies

Going beyond mod_rewrite

Changing mod_rewrite directory structures

         

Indy

5:22 am on Nov 25, 2004 (gmt 0)

10+ Year Member



I've recently discovered the power of the mod_rewrite function in Apache and have therefore spent a fruitful amount of time converting my URL structures from:

www.example.com\convoluted\directory\structure.php?with=complex&URL=strings

to

www.example.com\simple.html

This is all fine. But it has been such a successful transformation that it now upsets my sense of aesthetics that pre-existing external links to the site still display the convoluted URL string.

Unless I'm missing something very obvious (always possible) I can't see any way to rectify this short of getting the linking web sites to change the URL to which they're linking.

Am I missing something? Can this be tidied up easily?

bloke in a box

10:14 am on Nov 25, 2004 (gmt 0)

10+ Year Member



Use .htaccess again to create a 301 / 302 redirect for the urls?

Alternatively you will need to speak with those webmasters. :)

Indy

7:34 pm on Nov 25, 2004 (gmt 0)

10+ Year Member



> Use .htaccess again to create a 301 / 302 redirect for the urls?

I was a bit worried about doing that because essentially I'd be redirecting the page to itself, which seemed like the kind of thing that could easily end in tears. I'll try it for one page and see if it works though. Thanks.

bloke in a box

3:42 pm on Nov 26, 2004 (gmt 0)

10+ Year Member



Hrm, I see what you mean but sure a Permanently Moved redirect wouldn't penalise you? as you're assisting the search engines in telling them that the page has moved.

Unless I'm missing something obvious?

Indy

4:35 am on Dec 1, 2004 (gmt 0)

10+ Year Member



I was actually more worried about some kind of infinite loop, ie original page 301 redirects to new page which mod_rewrites back to original page... which then 301 redirects again (?)

Then I thought that fear might be founded on a misunderstanding of how mod_rewrites and 301s work, so over the weekend I sat down and tried it on one page and, sure enough, putting the 301 in seemed to slow the loading of a page to a crawl and then an eventual 404 error.

I wasn't completely convinced this was due to any kind of infinite looping, but regardless of what variation I tried it either a) didn't work at all or b) resulted in locking the page up as described above

I googled for solutions but without much success. Eventually I gave up on that approach. I think what I'm going to do now is this:

make a copy of my existing pages in
\complex\directory\structure\with?long=URL

to

\difficult\directory\structure\with?long=URL

and do mod_rewrites to the latter

Then once that's set up, I'll remove my current

\complex\directory\structure\

and add a whole heap of 301 redirects to pick up existing external links and redirect them to the new, short URLs.

Seems a convoluted process to me, but I can't seem to get it to work any other way.

jdMorgan

4:47 am on Dec 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Indy,

Welcome to WebmasterWorld!

WebmasterWorld member WitchKing has recently posted a solution to this "infinite loop problem" in this thread [webmasterworld.com] in the Apache forum.

Jim

Indy

9:14 pm on Dec 1, 2004 (gmt 0)

10+ Year Member



That's great. Thanks Jim - a far more sensible place to have the discussion...