PDA

View Full Version : htaccess - Tutorial



Luckyrare
11-02-2007, 07:57 PM
Bored so yah, Ive written this tutorial on some things on .htaccess

Banning IPs

Now, I wouldn't recommend banning IPs due to you may block out more than one person (maybe thousands)

All you need to do is replace "00.00.00" with the persons IP. If you want to not allow anyone to view it, just replace the IP with all


deny from 00.00.00

SEO Friendly URLs

I used to use this on my vbulletin at one point, I use it quite oftenly in my coding. It can be used with $_GET to make the URL search engine friendly (plus it looks better)



RewriteEngine on
RewriteRule ^([^/.]+)$ myscript.php?get=$1
So if I now typed in http://www.eg.com/anything it would load http://www.eg.com/myscript?get=anything

Error pages

Error pages are very simple to make. All you need to type is "ErrorDocument (error code) /(your page)"

eg. File can not be found

ErrorDocument 404 /404.htmlFor all your error codes check out w3.org
http://www.w3.org/Protocols/HTTP/HTRESP.html

Redirect
I personally prefer to redirect in the page using html but anyway here we go...


Redirect /oldfile.html /newfile.html


I am bored of writing this now, anyway I hope this helped some people.

timROGERS
11-02-2007, 08:17 PM
For anyone that can't see, the "SEO Friendly URLs" is MOD_REWRITE.

Want to hide these adverts? Register an account for free!