Welcome to WebmasterWorld Guest from 107.20.75.63

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

log redirects

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 15, 2004
posts:941
votes: 0


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)

Administrator

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

joined:Aug 10, 2004
posts:10544
votes: 8


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

Senior Member from US 

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

joined:Apr 9, 2011
posts:12714
votes: 244


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)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Dec 13, 2009
posts:943
votes: 0


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)

Administrator

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

joined:Aug 10, 2004
posts:10544
votes: 8


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

Senior Member from US 

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

joined:Apr 9, 2011
posts:12714
votes: 244


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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 15, 2004
posts:941
votes: 0


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)

Senior Member from US 

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

joined:Apr 9, 2011
posts:12714
votes: 244


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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 15, 2004
posts:941
votes: 0


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

Senior Member

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

joined:July 3, 2006
posts: 3123
votes: 0


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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 15, 2004
posts:941
votes: 0


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)

Senior Member from US 

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

joined:Apr 9, 2011
posts:12714
votes: 244


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