Reputation: 11
I am looking for a solution to hide param keys from my url
for example /page1.php?city=Lahore
I want it to rewrite as /page1/Lahore
but the most important thing is Lahore is not a directory exist on server I want it to point to same file page1.php just rewrite url externally
thanks
Upvotes: 0
Views: 51
Reputation: 7080
try this code for .htaccess file
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /projectfoldername/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^page1/(.+?)/?$ /projectfoldername/page1.php?key=$1 [L,QSA]
page1.php code will be
<?php
echo $_REQUEST['key'];
?>
then call http://localhost/projectfoldername/page1/1947
output will be :1947
Upvotes: 0
Reputation: 57
create an .htaccess file from the root and paste this code
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^page1/(.*)? /page1.php?city=$1 [L]
or you could also put it in your website apache conf file.
Upvotes: 1