It rewrite url like :-
http://www.rootdirectory.com/index.php?sate=rajasthan&city=jaipur&land=malviyanagar
to :-
http://www.rootdirectory.com/rajasthan/jaipur/malviyanagar
create a .htaccess file on root directory and paste following code
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9]+|)/?$ index.php?state=$1 [QSA]
RewriteRule ^([a-zA-Z0-9]+|)/([a-zA-Z0-9]+|)/?$ index.php?state=$1&city=$2 [QSA]
RewriteRule ^([a-zA-Z0-9]+|)/([a-zA-Z0-9]+|)/([a-zA-Z0-9]+|)/?$ index.php?state=$1&city=$2&land=$3 [QSA]
After used it code you can access your query string value like :-
And last on http://www.rootdirectory.com/index.php
paste following code :-
<div>
<a href="http://www.rootdirectory.com">home</a>
<a href="http://www.rootdirectory.com/rajasthan">Rajasthan</a>
<a href="http://www.rootdirectory.com/delhi/newdelhi">New Delhi</a>
<a href="http://www.rootdirectory.com/rajasthan/jaipur/malviyanagar">Malviya Nagar</a>
</div>
<?php
echo "<h2>".$_GET['state']."</h2>";
echo "<h2>".$_GET['city']."</h2>";
echo "<h2>".$_GET['land']."</h2>";
?>
http://www.rootdirectory.com/index.php?sate=rajasthan&city=jaipur&land=malviyanagar
to :-
http://www.rootdirectory.com/rajasthan/jaipur/malviyanagar
create a .htaccess file on root directory and paste following code
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9]+|)/?$ index.php?state=$1 [QSA]
RewriteRule ^([a-zA-Z0-9]+|)/([a-zA-Z0-9]+|)/?$ index.php?state=$1&city=$2 [QSA]
RewriteRule ^([a-zA-Z0-9]+|)/([a-zA-Z0-9]+|)/([a-zA-Z0-9]+|)/?$ index.php?state=$1&city=$2&land=$3 [QSA]
After used it code you can access your query string value like :-
And last on http://www.rootdirectory.com/index.php
paste following code :-
<div>
<a href="http://www.rootdirectory.com">home</a>
<a href="http://www.rootdirectory.com/rajasthan">Rajasthan</a>
<a href="http://www.rootdirectory.com/delhi/newdelhi">New Delhi</a>
<a href="http://www.rootdirectory.com/rajasthan/jaipur/malviyanagar">Malviya Nagar</a>
</div>
<?php
echo "<h2>".$_GET['state']."</h2>";
echo "<h2>".$_GET['city']."</h2>";
echo "<h2>".$_GET['land']."</h2>";
?>
No comments:
Post a Comment