homepage Welcome to WebmasterWorld Guest from 54.197.147.90
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
very basic .htaccess question
nickreynolds




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

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

 

incrediBILL




msg:4477606
 7:49 pm on Jul 20, 2012 (gmt 0)

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]

lucy24




msg:4477644
 10:10 pm on Jul 20, 2012 (gmt 0)

you should give them a 404 page


Could we compromise on 410 "It was here, but it's gone"?

g1smd




msg:4477654
 10:36 pm on Jul 20, 2012 (gmt 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.

incrediBILL




msg:4477682
 11:06 pm on Jul 20, 2012 (gmt 0)

True, 410 would probably be better but not necessarily used by all the lamer crawlers.

nickreynolds




msg:4478362
 8:36 am on Jul 24, 2012 (gmt 0)

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.

lucy24




msg:4478469
 4:57 pm on Jul 24, 2012 (gmt 0)

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.

incrediBILL




msg:4478477
 5:38 pm on Jul 24, 2012 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved