How to create .htaccess in centos - IT VIET

Technology Hardware & Solution Provider

Wednesday, March 4, 2015

How to create .htaccess in centos

How to create an .htaccess file on Centos.
Get set : 
- Preparing content in htaccess file.  
- vi /etc/httpd/conf/httpd.conf
<Directory "/var/www/html">

Options Indexes FollowSymLinks
Change    AllowOverride None   To   AllowOverride All

Order allow,deny
Allow from all

After that :
You find rows 317 (<Directory "/var/www/html"> ) and paste content in htaccess file you prepare before.
 You can following as below. 
<Directory "/var/www/html">
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^contact.html$ index.php?key=contact
RewriteRule ^privacy.html$ index.php?key=privacy
RewriteRule ^post.html$ index.php?key=post
RewriteRule ^login.html$ index.php?key=login
RewriteRule ^registry.html$ index.php?key=registry
RewriteRule ^index.html index.php
RewriteRule ^clip-([0-9]+)-(.*).html$ index.php?key=detail&idTin=$1

RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) http://%1/$1 [R=301,NE,L]
02. Restart httpd services.
service httpd restart
 ====>>  Wish you a good success ! <<=======

No comments:

Post a Comment