Welcome to WebmasterWorld Guest from 54.147.220.66

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

log redirects

   
3:02 pm on Nov 29, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



i was wondering if there is a way to log 301 redirects issued from htaccess, just by using php, no apache modifications (no htaccess rules, no http.conf modifications, no apache logs)
just plain php code.
4:49 pm on Nov 29, 2013 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



no.
9:46 pm on Nov 29, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



On the other hand: If you take all the pages you're currently redirecting, and instead rewrite them to a php page which does the lookup and issues the 301, it should be fairly trivial to log that activity. Where "fairly trivial" = I have no idea how to do it,* but I'm confident that someone hereabouts does.


* I can follow directions at php dot net, but only if I know where to look in the first place.
6:44 pm on Nov 30, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Pretty simple if you use a PHP script as Lucy suggests.

Either append to your 301 log file like:

file_put_contents('/var/log/httpd/301.log', "\nA message containing pertinent details", FILE_APPEND);


Or insert into your database table.

Then simply issue the correct header:

header('Location: http://www.example.com', true, 301);
8:56 pm on Nov 30, 2013 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



no apache modifications
rewrite them to a php page
these are mutually exclusive
9:45 pm on Nov 30, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



Picky, picky :P But the 301s have to come from somewhere. So if you replace the existing redirects with a rewrite to a different page, it barely counts as a "modification".

That's assuming the redirects originate in htaccess. (OP specifically said they do.) If they are all in-page redirects, it's a whole nother ballgame.

omoutop, do you have access to the config file? If yes, why are you also using htaccess?
6:49 am on Dec 2, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



6 months ago we change out site - new design and new urls
so we had around 25000 301 redirects
now we change some urls again and old redirects must be replaced with new ones

we need a way to monitor which 301 rules are still active (user bookmarks, bots, anything) and which ones are no longer apply so as to clear out this 301 list

the php file seems good solution - i can move all 301 rules to a table in database and monitor from there.

i will give it a try
9:29 am on Dec 2, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



The day after you remove a no-longer-needed redirect, some major search engine will swing by and request three hundred of your old URLs.

Fact.
11:10 am on Dec 2, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



:)
12:07 am on Dec 3, 2013 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



I know you mentioned "no apache logs", but I'm curious... are your access logs not available?
8:36 am on Dec 3, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



no penders
i have no access to any logs, to no conf files
only access i got is limited ftp
7:25 pm on Dec 3, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



No logs AT ALL? Sounds like it's time to go host-shopping.