RSS

Category Archives: .htacess

URL redirect through

http://www.a2zwebhelp.com/url-rewrite-htaccess

 

The following code will rewrite anyfile.php to anyfile.html

RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php

The following code will rewrite index.php to index

RewriteEngine on
RewriteRule ^index index.php

 

Few Example to create SEO friendly URL.

1. Rewrite product.php?id=1 to product-1.html

RewriteEngine on
RewriteRule ^product-([0-9]+)\.html$ product.php?id=$1

 

2. Rewrite product.php?id=12 to product/cat/12.html

RewriteEngine on
RewriteRule ^product/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ product.php?id=$2

 

3. Rewrite domain.com/member.php?username=arup to domain.com/arup

RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?username=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ user.php?username=$1

 

4. Rewrite domain.com/users.php?id=username&page=2 to domain.com/username/2

RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)$ users.php?user=$1&page=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/$ users.php?user=$1&page=$2

 

Advertisements
 
Leave a comment

Posted by on October 14, 2014 in .htacess

 

Tags: ,

How to write .htacess files

<li><a href=”<?php echo $SITEURL; ?>sub-page-content.php?$page<?php echo  $row22[‘id’] ?>”><?php  echo $row22[‘subpage_title’];?></a></li>

http://www.example.com/sub-page-content.php?subpage=1

i want to remove the query string in the last

This code is replace with old code

<li><a href=”<?php echo $SITEURL; ?><?php echo $page= $row22[‘subpage_url’] ?>.html”><?php  echo $row22[‘subpage_title’];?></a></li>

used this code

.htacess code

RewriteEngine On
RewriteRule ^([a-zA-Z0-9-/]+).html$ sub-page-content.php?subpage=$1
RewriteRule ^([a-zA-Z0-9-/]+).html/$ sub-page-content.php?subpage=$1

 
Leave a comment

Posted by on December 5, 2012 in .htacess