Welcome to WebmasterWorld Guest from 23.20.86.177

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

very basic .htaccess question

     
5:33 pm on Jul 20, 2012 (gmt 0)

Preferred Member

10+ Year Member Top Contributors Of The Month

joined:May 1, 2005
posts:412
votes: 2


I had a wordpress blog in a separate folder on my site. I decided to remove the blog - so the folder and everything in it is gone.

So I went to cpanel file manager and set up a .htacess file (yes I put the dot in)

I couldn't redirect the whole folder so tried to redirect a single page using this code


Redirect 301 /Foldername/WPPostName http://www.example.com/index.htm

Foldername is the name of the folder and WPPostname is the name of the individual post. It's on the first line of code and consists of just one line.

According to my even less than rudimentary understanding this should work. Can anyone suggest why it doesn't?

Oh just to add - the .htaccess is in the root folder (public_html) and the code editor says it's in utf-8
7:49 pm on July 20, 2012 (gmt 0)

Administrator from US 

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

joined:Jan 25, 2005
posts:14664
votes: 99


For starters, if you removed the blog you should give them a 404 page, not a 301 redirect.

I would send all of these people to a custom 404 telling them the blog is gone and put a redirect in that page, either meta redirect for the browser or you could do a redirect in a PHP page.

Anyway, the proper way to redirect an entire folder would be a RewriteRule:

RewriteEngine on
RewriteRule ^Foldername/.* http://www.example.com/ [R=301,L]
10:10 pm on July 20, 2012 (gmt 0)

Senior Member from US 

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

joined:Apr 9, 2011
posts:14146
votes: 541


you should give them a 404 page


Could we compromise on 410 "It was here, but it's gone"?
10:36 pm on July 20, 2012 (gmt 0)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 0


The .* in that pattern is redundant and can be removed.

With a redirect in a PHP page any notice on that page would be unreadable.

If the content has gone, serve "410 Gone" with a human-readable message explaining what is going on.
11:06 pm on July 20, 2012 (gmt 0)

Administrator from US 

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

joined:Jan 25, 2005
posts:14664
votes: 99


True, 410 would probably be better but not necessarily used by all the lamer crawlers.
8:36 am on July 24, 2012 (gmt 0)

Preferred Member

10+ Year Member Top Contributors Of The Month

joined:May 1, 2005
posts:412
votes: 2


Thanks Bill

I've used your inital code you gave me for the time being
and it's working fine.
I will look into the 404/410 thing - it's not something I normally have to bother with as it's very rare that i have a page that becomes redundant or is moved.
4:57 pm on July 24, 2012 (gmt 0)

Senior Member from US 

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

joined:Apr 9, 2011
posts:14146
votes: 541


not necessarily used by all the lamer crawlers

Do we have to design for lame crawlers now? :(

The practical difference between 404 and 410 is that a 410 isn't automated-- that is, the server doesn't remember that some file was there for years and years and now it's gone. Heck, the server can't even remember someone it met two seconds ago :)

You can often double up and send humans to the same physical error page for both 404 and 410. They probably don't care whether the page used to exist, just that it isn't there now. That's assuming you're not dumping popular pages that people had bookmarked. But be sure you send humans somewhere. The default 410 page is scary.
5:38 pm on July 24, 2012 (gmt 0)

Administrator from US 

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

joined:Jan 25, 2005
posts:14664
votes: 99


Maybe I'll just put this on my tombstone:
"410 Gone but not forgotten"
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members