Jump to content

What .htaccess mods do you commonly employ

Whether you're a seasoned veteran or a struggling beginner, Web Radiance is the web development and web design forum for you. You'll find answers to all your HTML, CSS, SEO, and Programming needs. Pull up a chair and stay awhile.

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

What .htaccess mods do you commonly employ Rate Topic: -----

#1 User is offline   Beavis 

  • W.R. Corporal
  • Group: Members
  • Posts: 167
  • Joined: 24-March 08

Posted 02 June 2008 - 12:47 AM

I`ve been doing some reading recently about the potential uses of ".htaccess" files.

What does your typical .htaccess file look like?
Do you often modify it or just use the hosting company`s (blank) default file.
0

#2 User is offline   haku 

  • 日本語 Ninja
  • Group: Members
  • Posts: 652
  • Joined: 21-September 07
  • Gender:Male
  • Location:Yokohama, Japan

Posted 02 June 2008 - 01:30 AM

.htaccess files are pretty handy things. I use different commands for different areas and/or sites, but here are some of the things I use it for:

- forwarding non www links to the www domain (for cookie related reasons)
- allowing the use of alternate file extensions rather than php
- mod rewriting in which a page is accessed using the .html extension, but is in fact a .php extension (user cant tell the difference)
- setting area specific php.ini settings
- creating custom http status pages (301, 302, 400, 500 etc)
- setting the directory to not list if someone pics a non-existant file (access denied page is shown instead of the directory listing)
- setting the index page for a folder for when no page-name is added to the directory in the URL (ex: user enters www.example.com and gets www.example.com/default_page.php)

And more I'm sure! I just can't think of anything off the top of my head.
<a href="http://www.jaypan.com" target="_blank">Jaypan</a>
<a href="http://www.dudes-japan.com" target="_blank">Dudes Japan</a>
0

#3 User is offline   Beavis 

  • W.R. Corporal
  • Group: Members
  • Posts: 167
  • Joined: 24-March 08

Posted 02 June 2008 - 01:43 AM

haku

Thanks for the reply.

Is there some kind of "standard" .htaccess file that you use before adding further site specific customisation?

It seems to me that some of the things you listed would be useful to have on ANY site and
hence might be used by default rather than re-inventing the wheel each time round.

Much the same as CSS resets are used.
0

#4 User is offline   haku 

  • 日本語 Ninja
  • Group: Members
  • Posts: 652
  • Joined: 21-September 07
  • Gender:Male
  • Location:Yokohama, Japan

Posted 02 June 2008 - 04:00 AM

I don't have a standard one that I use, but I could probably put one together!

Here are some of the commands I mentioned:

Don't list files in directory:
Options -Indexes


Set default index page for directory:
DirectoryIndex default-page.php


Set my own file extension other than .php:
AddHandler application/x-httpd-php5 .ajax

note: I use the .ajax extension for all of my server-side ajax scripts, just as my own sort of filing system. They are all php files though.
<a href="http://www.jaypan.com" target="_blank">Jaypan</a>
<a href="http://www.dudes-japan.com" target="_blank">Dudes Japan</a>
0

#5 User is offline   Beavis 

  • W.R. Corporal
  • Group: Members
  • Posts: 167
  • Joined: 24-March 08

Posted 02 June 2008 - 04:41 AM

Thanks a lot.

Can you recommend a good book or even an online resource
that explains .htaccess files in depth?

Would a book on Apache cover it you think?
0

#6 User is offline   marcamos 

  • W.R. General
  • Group: Administrators
  • Posts: 2,849
  • Joined: 04-April 06
  • Gender:Male
  • Location:Massachusetts - USA

Posted 02 June 2008 - 05:32 AM

Great tips haku - they'll help me in the future!
0

#7 User is offline   haku 

  • 日本語 Ninja
  • Group: Members
  • Posts: 652
  • Joined: 21-September 07
  • Gender:Male
  • Location:Yokohama, Japan

Posted 02 June 2008 - 08:10 AM

I've pondered trying to buy something on htaccess commands, but so far all the stuff I've picked up has just been surfing around on the internet and seeing what I can find. There are forums dedicated to .htaccess files (you may even see my username on some of them!), and there are countless tutorials out there.

Actually, everything I've picked up web development related has been stuff I've found on the internet. I don't own even one book on web design development! I rape google. :D
<a href="http://www.jaypan.com" target="_blank">Jaypan</a>
<a href="http://www.dudes-japan.com" target="_blank">Dudes Japan</a>
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users