Can I use the word redirect in every sentence? Let's find out.
July 31, 2006 7:22 AM   Subscribe

Is there a way that I can tell if a page has been redirected by conf.d or .htaccess?

I'm about to release a redesigned website and the structure is so different (and the website so large) that I have over 500 redirects to be put in either an .htaccess or conf.d file.

Since .htaccess and conf.d redirects don't notify the user that they're being redirected, I'd like to be able to pull something (perhaps from the HTTP Referer?) to say "if page is redirected, print div to say change your bookmarks."

Anyone know how to do this?

p/s. I've accomplished redirect notifications on 404 pages with mod rewrite, but since there are so many in this case, I want to avoid skewed 404 results in our site statistics.
posted by 10ch to Technology (7 answers total) 1 user marked this as a favorite
You could add a variable to the redirect so that the target page knew it was a redirect target.


Redirect 301 /oldpage.html
posted by justkevin at 7:35 AM on July 31, 2006

justkevin, I was going to suggest the same thing, but the problem is that if the user then bookmarks that URL (including the variable), it will always come up with the notification when they return to it.
posted by staggernation at 7:45 AM on July 31, 2006

you could check the referrer string? I don't know if the referrer shows up as the redirected page or as the initial referrer, but if it is the former you could only display a notice when the user came from urls on the old-url list.
posted by soma lkzx at 7:52 AM on July 31, 2006

No, I believe the original referrer is preserved when the request is redirected.
posted by staggernation at 8:00 AM on July 31, 2006

If you use RewriteRule you can set a cookie. Also, if you have that many redirect and are going to use mod_rewrite, I'd strongly suggest looking into using RewriteMap.
posted by sbutler at 8:04 AM on July 31, 2006

When I switched domains and had some overlap time, I redirected (with a rewriterule) ALL requests for the old domain to a single script, which would display "Change your bookmarks" (along with what the new URL would look like) and then auto-redirect to the new place with a Location header (preserving all pathinfo). Just a few lines of Perl.
posted by jozxyqk at 8:48 AM on July 31, 2006

jozxyqk has a point.

Your question is a bit of an X-Y problem "I'm handling the changes like this, how can I do that?" -- what if you handled it a different way?

But if you're printing a DIV which says "moved, changed your bookmarks", why not print javascript right after it which sets a "they've seen the div" cookie? After than, the DIV doesn't get printed because you detect the cookie. Or, indeed, increment the cookie value and give up on them after three tries.
posted by AmbroseChapel at 2:37 PM on July 31, 2006

« Older BreastPumpFilter   |   Whitewater Rafting near NYC Newer »
This thread is closed to new comments.