Development Blog by Professionals
.htaccess
.htaccess SSI Variables
Jul 22nd
SSI Variables
DATE_GMT=Sun Mar 8 22:58:56 2009 DATE_LOCAL=Sun Mar 8 15:58:56 2009 DOCUMENT_NAME=FOOTER.html DOCUMENT_ROOT=/root-srv/protected/askapache.com/sec DOCUMENT_URI=/includes/FOOTER.html GATEWAY_INTERFACE=CGI/1.1 HTTP_ACCEPT=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 HTTP_ACCEPT_CHARSET=ISO-8859-1,utf-8;q=0.7,*;q=0.7 HTTP_ACCEPT_ENCODING=gzip,deflate HTTP_ACCEPT_LANGUAGE=en-us,en;q=0.5 HTTP_CACHE_CONTROL=max-age=0 HTTP_CONNECTION=keep-alive HTTP_COOKIE=__qca=12298910-686528-46510; __utmb=50625.1.0.11311 HTTP_HOST=www.askapache.com HTTP_KEEP_ALIVE=300 HTTP_REFERER=http://www.askapache.com/htaccess/htaccess.html HTTP_USER_AGENT=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6 (.NET CLR 3.5.30729) LAST_MODIFIED=Sun Mar 8 14:53:50 2009 PATH=/bin:/usr/bin:/sbin:/usr/sbin QUERY_STRING= REMOTE_ADDR=24.123.215.60 REMOTE_PORT=4785 REQUEST_METHOD=GET REQUEST_URI=/htaccess/ SCRIPT_FILENAME=/root-srv/protected/askapache.com/sec/includes/FOOTER.html SCRIPT_NAME=/includes/FOOTER.html SCRIPT_URI=http://www.askapache.com/htaccess/ SCRIPT_URL=/htaccess/ SERVER_ADDR=64.111.114.111 SERVER_ADMIN=webmaster@askapache.com SERVER_NAME=www.askapache.com SERVER_PORT=80 SERVER_PROTOCOL=INCLUDED SERVER_SIGNATURE= SERVER_SOFTWARE=Apache/2.0.61 (Unix) PHP/4.4.7 mod_ssl/2.0.63 OpenSSL/0.9.7e mod_fastcgi/2.4.2 DAV/2 SVN/1.4.2 UNIQUE_ID=dnbtH0Bvcm8A2ZHqcAAAAM USER_NAME=
More SSI Information
htaccess Redirecting non-www to www with .htaccess
Jun 28th
If you want to redirect all non-www requests to your site to the www version, all you need to do is add the following code to your .htaccess file:
in your .htaccess file
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
This will redirect any requests to http://my-domain.com to http://www.my-domain.com. There are several benefits from doing that:
* It will avoid duplicate content in Google
* It will avoid the possibility of split page rank and/or split link popularity (inbound links).
* It’s nicer, and more consistent.
Note that if your site has already been indexed by Google without the www, this might cause unwanted side effects, like lost of PR. I don’t think this would happen, or in any case it would be a temporary issue (we are doing a permanent redirect, 301, so Google should transfer all rankings to the www version). But anyway, use at your own risk!
Something nice about the code above is that you can use it for any website, since it doesn’t include the actual domain name.
Redirecting www to non-www
If you want to do the opposite, the code is very similar:
in your .htaccess file
RewriteEngine On
RewriteCond %{HTTP_HOST} !^my-domain\.com$ [NC]
RewriteRule ^(.*)$ http://my-domain.com/$1 [R=301,L]
In this case we are explicitly typing the domain name. I’m sure it’s possible to do it in a generic way, but I haven’t had the time to work one out and test it. So remember to change ‘my-domain’ with your domain name! More >
friendly url with htaccess
Mar 4th
suppose you want /articles.php?cat=$1&art=$2 to become magazine/1/2
then you need these two rules:
#articles.php?cat=$1&art=$2
RewriteRule ^magazine/([^/]*)/([^/]*)$ /articles.php?cat=$1&art=$2&marker [L]
RewriteCond %{REQUEST_URI} /articles\.php [NC]
RewriteCond %{QUERY_STRING} ^cat=(.*)&art=(.*)
RewriteCond %{QUERY_STRING} !marker
RewriteRule (.*) http://mydomain/%1/%2? [R=301,L]
Top 5 Online .htaccess Mod Rewrite Rules Generator
Mar 1st
You might be aware of mod_rewrite rule and .htaccess file if you are using wordpress as your Blogging platform, .htaccess is the apache’s default directory level configuration files which can be used to password protect and redirect requests. Webmasters need to give special attentions to .htaccess on apache webserver as its very difficult to enforce all policies using just httpd.conf file. More >
.htaccess upload_max_filesize ini_set()
Jan 25th
I m PHP 5.2.0 / Apache
and I can’t access php.ini
I try to update .htaccess
and added
php_value upload_max_filesize “25M”
php_value post_max_size “25M”
However it will give me “Internal Server Error” More >
Add Trailing Slash to the End of the URL with .htaccess Rewrite Rules
Aug 3rd
For a website that has URLs that end with a slash (/), it’s a good practice to ensure that all url links been parsed by the web server ended with trailing slash, even if visitors forget to enter the ending slash. This avoid visitors been served with 404 Page Not Found or Page Cannot be Displayed error as some webservers treat links without trailing slash as a file name instead of directory, and thus unable to locate the documents. It also eliminates the possibility that both pages with same content, one with slash at the end and another without, been viewed by search engines as duplicate content.
As an example, all hits to http://www.mydigitallife.info/contact should be redirect to http://www.mydigitallife.info/contact/. More >
Password Protecting Your Pages with htaccess
Jul 30th
Creating the password file
The first step is to create a simple text file that will store your username and password, separated by a colon (:). The small catch is that the password must be encrypted. Luckily, there are many free web-based utilities that will encrypt the password for you. Try one of these:
- 4WebHelp’s online .htpasswd encryption tool
- Alterlinks .htaccess password generator
- htmlite’s htpasswd encryption page
Simply enter your desired username and password in one of these pages and submit the form. You’ll get back a string similar to the following: More >
Php, MySql, .htaccess: friendly urls
Jul 26th
Php, MySql, .htaccess: friendly urls
There are a lot of tutorials that show how to change an address like:
- www.mysite.com/products.php?product_id=1234
into others like:
- www.mysite.com/products/1234
- www.mysite.com/products/1234.html
In this article I’d like to go one step forward and to create something like:
- www.mysite.com/easy-to-remember-product-name
- www.mysite.com/easy-to-remember-product-name.html More >
.htaccess Generator
Apr 3rd
| .htaccess File Wizard |
| The .htaccess is a simple method that allows you to customise the way the webserver works on a per directory basis. The .htaccess file is a simple ASCII text file, which when placed in a certain directory in your webspace, will cause the webserver to use that configuration on all files in that directory and any files in any subdirectories.
When you have finished creating your .htaccess code, click on the “Select All” button and copy (CTRL + C) and paste (CTRL + V) the code into a text editor and save the file as .htaccess. The .htaccess file should have the name “.htaccess” (all lowercase), and can either be created using a command line text editor when logged in using ssh or can be uploaded by ftp. |
How to Redirect a Web Page
Aug 8th
301 Redirect
301 redirect is the most efficient and Search Engine Friendly method for webpage redirection. It’s not that hard to implement and it should preserve your search engine rankings for that particular page. If you have to change file names or move pages around, it’s the safest option. The code “301″ is interpreted as “moved permanently”.
You can Test your redirection with Search Engine Friendly Redirect Checker
Below are a Couple of methods to implement URL Redirection More >


