In: .htaccess
27 Aug 2010Sometimes we face limitations of file size allowed to be uploaded using our PHP script. To overcome these problems we can simply add following lines to our .htaccess file and increase allowed size of files being uploaded using PHP (or some other scripts). 1 2 3 4 php_value upload_max_filesize 10M php_value post_max_size 10M php_value max_execution_time [...]
In: .htaccess
3 Aug 2010When moving your website from one domain to another, or just simply changing URLs and link, it is a good idea to use htaccess permanent redirect 301, as you users won’t be looking at 404 page. This is not the only benefit from htaccess permanent redirect 301, you get bonus from Google as well. If [...]
In: .htaccess
20 Jul 2010To have your website going through secure connection, you can use htaccess redirect. You can redirect all visits from that are not going through https, and force your website to use secure connection by using only htaccess. Us following htaccess snippet to force https. 1 2 3 RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
In: .htaccess
20 Jul 2010In order to force your domain using www, you can use following .htaccess snippet. This snippet makes htaccess add www to your domain name. 1 2 3 4 RewriteEngine on rewritecond %{http_host} ^stuntsnippets.com [nc] rewriterule ^(.*)$ http://www.stuntsnippets.com/$1 [r=301,nc]
In: .htaccess
13 Jul 2010If you have problems with other websites stealing your bandwidth, and you want to prevent hotlinking, use following snippet and place code in your htaccess file: 1 2 3 4 RewriteEngine On RewriteCond %{HTTP_REFERER} !^http://(.+\.)?my-website-url\.com/ [NC] RewriteCond %{HTTP_REFERER} !^$ RewriteRule .*\.(jpg|gif|bmp|png)$ http://hotlink.my-website-url.com/hotlinking-is-not-allowed.jpg [L]
In: .htaccess
10 Jul 2010In order to setup custom 404 page, and prevent user from viewing default error page, you can use ErrorDocument 404 in htaccess. Just copy/paste following snippet into your .htaccess file: ErrorDocument 404 /pages/errorDocument/error404.php More about ErrorDocument directive ErrorDocument directive doesn’t have to be used only for errors 404, and it can do couple of things [...]
In: PHP
5 Jul 2010Considering that you want to have nice URLs that are SEO optimized, you would have to pass parameters without using “?”. In this case we can use redirection htaccess. To make simple example, see snippet below: 1 2 3 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?page=$1 Use redirection htaccess: This redirection snippet will [...]
In: .htaccess
1 Jul 2010If you have a need to block person or a bot on your website, there is an easy way to do this using htaccess. 1 2 3 4 order allow,deny deny from 4.4.4.4 deny from 22.22.22.22 allow from all After deny from, you will add IP address that you want to block. You can add [...]