More Fun With .htaccess Files
December 7, 20073 things you can do with .htaccess files that we probably haven’t mentioned on this blog before:
1). Put error messages in the .htaccess file as opposed to creating separate web pages. There is no real reason to do this. However, it is pretty cool, in that you can pretty much create a website using just an .htaccess file and no other files.
ErrorDocument 404 "<html><head><title>This Is a Demo</title> </head><body>Here is some cool stuff:<ul><li>Some text</li> <li><a href='/'>A Link</a></li></ul></body></html>"
2). Use mod_rewrite to rewrite a URL internally with no redirect. I don’t believe that we have ever covered this, but it is very handy:
RewriteEngine on RewriteRule ^happyurl\.php$ crazyurl.php?with=some&extra=bits[L]
3). How about using mod_rewrite to redirect any queries to a certain page if the page/directory that is being accessed doesn’t exist.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /oopsydaisy.php [L]
Note, don’t get this confused with with error documents. This .htaccess rule give out a 200 OK in the http headers, which tells search engines that the pages exists, where as the error document will give out the relevant header - 404 or whatever, telling the search engines what the issue with the url they are accessing is.
James
SEO Programmer
1 Comment
RSS feed for comments on this post
TrackBack URI
Leave a comment
Just Search Weblog
Archives:
Pages:
Meta:
Categories:
- Accessibility
- Affiliate Marketing
- Content Writing
- Cowboys
- Downloads
- Internet Marketing
- Job Vacancies
- Latest News
- Pay Per Click
- Press Releases
- Search Engine Optimisation
- Testimonials
- Web Analytics
- XHTML















James.
I have just bought a domain that has a few hundred pages. As I’m re-developing the site I have removed all these pages. However the bots are currently still looking for them - should I just let them not find them and then they’ll de-index them over time or should I do something fancy with the .htaccess file?
Comment by gadget December 7, 2007 @ 5:00 pm