Post Reply 
Using .htaccess to optimize and secure website
05-11-2011, 10:17 AM
Post: #1
Using .htaccess to optimize and secure website
Use .htaccess file to optimize and better secure your website: the protection of critical files, upload limit, 301, custom error pages, short listing directory contents, compressed content ...
CONTENTS ENTRY INTO FILE htaccess.txt
- Htaccess file protect file

Quote:<files .htaccess>
order allow, deny
deny from all
</ files>
- Anti spam comments
Quote:RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .comments-post\.php*
RewriteCond %{HTTP_REFERER} !.*yourdomain.com.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]
- Redirect 301

Quote:Redirect 301 /old.php http://www.yourdomain.com/new.php
- Create custom error page
Quote:ErrorDocument 404 /notfound.php
ErrorDocument 403 /forbidden.php
ErrorDocument 500 /error.php

UPLOAD TO SERVER htaccess.txt

Using ftp client (using ASCII mode) and rename the file.. htaccess

CHMOD .htaccess file to 644.

Thanks Regards
SheKHAR

Thanks 123Systems.Net And Freevps.Us.
User Tools
Quote this message in a reply


05-11-2011, 02:17 PM (This post was last modified: 05-11-2011 03:15 PM by dio98.)
Post: #2
RE: Using .htaccess to optimize and secure website
Nice tutorial.
BTW I have a question about:

ErrorDocument 404 /notfound.php
ErrorDocument 403 /forbidden.php
ErrorDocument 500 /error.php

Will it get the text from the file you choose?

Rep me if this helped you.
User Tools
Quote this message in a reply
05-12-2011, 06:13 AM
Post: #3
RE: Using .htaccess to optimize and secure website
yes it will display whatever you tell it to in those php files.
User Tools
Quote this message in a reply
05-12-2011, 01:12 PM
Post: #4
RE: Using .htaccess to optimize and secure website
Nice tutorial! But you can do this on CPanel with ease, right?

Though coding it on .httaccess can be a nice way of learning, I guess.
User Tools
Quote this message in a reply
05-15-2011, 06:55 PM
Post: #5
RE: Using .htaccess to optimize and secure website
top tutorial
User Tools
Quote this message in a reply
05-17-2011, 03:58 AM
Post: #6
RE: Using .htaccess to optimize and secure website
Great codes I will try some of them out soon Wink

[Image: impad.png]
User Tools
Quote this message in a reply
05-17-2011, 08:46 PM (This post was last modified: 05-18-2011 05:06 AM by Infinity.)
Post: #7
RE: Using .htaccess to optimize and secure website
how is that script exactly working?/ Can someone of you can tell it me in english, I don`t know php, but perhaps I would going to learn a little bit php in the summer holidays?

Code:
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .comments-post\.php*
RewriteCond %{HTTP_REFERER} !.*yourdomain.com.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]
User Tools
Quote this message in a reply
05-18-2011, 01:47 PM
Post: #8
RE: Using .htaccess to optimize and secure website
htaccess files are not php. They are basically config files for apache. Read http://httpd.apache.org/docs/current/how...ccess.html
User Tools
Quote this message in a reply
05-20-2011, 01:39 AM
Post: #9
RE: Using .htaccess to optimize and secure website
(05-11-2011 10:17 AM)ShEkhAr Wrote:  <files .htaccess>
order allow, deny
deny from all
</ files>
[/quote]

That is typically done by default but there is no real reason to use .htaccess when on a VPS. Just turn it off and add what you would put there into the vhost for your domain in the main httpd.conf

KVM2 (VPS 15, 19 and 25) Munin report | Check your VPS 15, 19 or 25's IOPS usage
User Tools
Quote this message in a reply
05-20-2011, 05:03 AM
Post: #10
RE: Using .htaccess to optimize and secure website
Not if you are the only one using it anyway.
User Tools
Quote this message in a reply
Post Reply 


Forum Jump:



User(s) browsing this thread:
1 Guest(s)