QAds
Apple iPod shuffle 1 GB Pembe
$35.00
Nikon D90 DX 12.3MP Digital SLR Camera with 18-105mm f/3.5-5.6G ED AF-S VR DX Nikkor Zoom Lens
$0.69
Apple iPod nano 8 GB Yesil
$88.21
Apple iPod shuffle 1 GB Yesil
$35.00
:: HOME APACHE htaccess configuration
 
htaccess configuration

.htaccess is used to set configuration of any specific directory. Nowadays, it mostly uses to create Search Engine Friendly pages. You can redirect any url typed with your domain to specific url. To be able to use you need modify your httpd.conf which is server configuration file and change AllowOverride to "all" and mod_rewrite  module for APACHE server. Than you can use .htaccess.

 

I will show some basic examples to help you learn how to use it.

 

RewriteEngine on

RewriteRule !\.(js|ico|gif|jpg|png|CSS)$ index.PHP

 

Over here, !(pattern) is used when url doesn’t match pattern. It means, if users type any js, ico, gif. Jpg, png or CSS file, it doesn’t apply this rule. Except these, it will apply this rule and redirect any PHP, HTML file to index.PHP file.

 

If we want to redirect just HTML files like when users types product_ABC.HTML, I want to redirect it to, product.PHP?product=ABC. So this is also search engine friendly page because search engines likes HTML pages.

 

RewriteRule product_(.*)\.htm$  product.PHP?product=$1

 

Here, at first we define url and (.*) means any thing and it will go to second page we defined. $1 first (.*) and we can use many of these like

 

RewriteRule products_(.*)_(.*)\.htm$  products.PHP?category=$1&brand=$2

 

 

If you want to redirect a directory to other;

 

RewriteCond %{HTTP_HOST} ^tr.bounmis.com$ [OR]

 

RewriteCond %{HTTP_HOST} ^www.tr.bounmis.com$

 

RewriteRule ^(.*)$ http://www.bounmis.com/tr/ [R=301,L]

 

Here, rewriteCond shows condition you can see some words at the end [OR] means its has any more condition. R=301 means it is permanent address and L means it is last rule, end of [OR] for above conditions.

 

 

If you want to redirect any url like bounmis.com/category/1/brand/5

 

RewriteRule ^([A-Za-z0-9-]+)/([0-9]+)/([A-Za-z0-9-]+)/([0-9]+)/?$ products.PHP?$1=$2&$3=$4 [L]

 

These are mostly used examples .

 

At last I want to say that if your APACHE server uses CGI or fastcgi and you always get an error message like "No input file specified". Put [PT] at the end of rules

 

RewriteRule !\.(js|ico|gif|jpg|png|CSS)$ index.PHP [PT]