By
Gunjan · December 25, 2009
If you receive following error in the error logs
” PHP Parse error: syntax error, unexpected T_STRING”
Then you can add following line in the .htaccess file
php_flag short_open_tag X
Or
If your server is SuExec enabled then you can use following code in php.ini file
short_open_tag = X
By
Gunjan · December 11, 2009
In now a days its very easy to inject any forum.You can secure your forum by using following code in your .htaccess
#spam bots SetEnvIfNoCase User-Agent “^EmailSiphon” bad_bot SetEnvIfNoCase User-Agent “^EmailWolf” bad_bot SetEnvIfNoCase User-Agent “^ExtractorPro” bad_bot SetEnvIfNoCase User-Agent “^CherryPicker” bad_bot SetEnvIfNoCase User-Agent “^NICErsPRO” bad_bot SetEnvIfNoCase User-Agent “^Teleport” bad_bot SetEnvIfNoCase User-Agent “^EmailCollector” bad_bot #plagarism bot SetEnvIfNoCase User-Agent “^TurnitinBot” bad_bot #IP bot SetEnvIfNoCase User-Agent “^NPBot” bad_bot #Worm sign SetEnvIfNoCase User-Agent “^LWP::Simple” bad_bot SetEnvIfNoCase User-Agent “^lwp-trivial” bad_bot SetEnvIfNoCase User-Agent “^lwp” bad_bot SetEnvIfNoCase User-Agent “^LWP” bad_bot #Worm sign Order Allow,Deny Allow from all Deny from env=bad_bot
By
Gunjan · December 6, 2009
You can use following code in .htaccess file to parse php pages in html pages
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
To can check above code is working ir not? by creating one test page with following code
root@gunjan[~]#pico test.html
< html>
< head>
< body>
< h1>
< ?php echo "WORKING FINE!"; ?>
< /h1>
< /body>
< /html>
By
Gunjan · November 23, 2009
Your can redirect all http (Non-secure) URL to https by using following code in .htaccess file.
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
Your can redirect all https (Secure) URL to http by using following code in .htaccess file.
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^.*$ http://%{SERVER_NAME}%{REQUEST_URI} [L,R]
By
Gunjan · November 19, 2009
To disable the Directory listing for folders you need to create the .htaccess file under the each an every folder under which you want to disable the Directory listing and insert the following code in .htaccess file.
————
Options -Indexes
————-
By
Gunjan · November 17, 2009
If you are receiving 403 error message after browsing your domain than check the Apache error logs.
root@gunjan[~]tail -f /usr/local/apache/logs/error_log
[Tue Nov 17 19:38:32 2009] [crit] [client 192.168.0.2] (13)Permission denied: /home/admin/public_html/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
As per above logs it seems that the nobody user is not getting read and executing permission upto any of that folder.So make sure that the public_html and the subdomain are set read and executing permission for nobody user.
By
Gunjan · November 6, 2009
How to stop hotlinking from outsides domains.
You can stop the hotlinking from outsider domain by using following rule in .htaccess
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(.+.)?domain.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+.)?domain1.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+.)?domain2.com/ [NC]
RewriteRule .*.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L]
You can also display a 403 Forbidden Error page instead of an image (nohotlink.jpe)
Replace last line on above code with the following code
RewriteRule .*.(jpe?g|gif|bmp|png)$ – [F]
The default wordpress .htaccess file code is as follows
# BEGIN wordpress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_fileNAME} !-f
RewriteCond %{REQUEST_fileNAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END wordpress