haybeye
haybeye

Reputation: 131

mod_rewrite and apache clean hyperlinks

i've a php website and using mod_rewrite for clean urls.

my files:

villa.php about.php contact.php index.php 404.php

my villa.php is dynamic and works with mysql db. url example:

domain.com/villa?i=2&s=villaname

i want to use it like domain.com/villa/id/villaname

my .htaccess file looks like this:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$  $1.php [L,NC]

RewriteRule ^yazlik/(.*)/(.*)$ yazlik.php?i=$1&s=$2[L,NC]

but its not working. what is the right configuration for .htaccess file? any help would be great. thanks for your time.

Upvotes: 2

Views: 46

Answers (1)

Amit Verma
Amit Verma

Reputation: 41229

You can use this rule in your htaccess file

 RewriteRule ^villa/([0-9]*)/(.*)/?$ /villa?i=$1&s=$2 [QSA,NC,L] 

 RewriteEngine On
 RewriteBase /
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$  $1.php [L,NC]

 RewriteRule ^yazlik/(.*)/(.*)$ yazlik.php?i=$1&s=$2[L,NC]
 RewriteRule ^villa/([0-9]*)/(.*)/?$ /villa?i=$1&s=$2 [QSA,NC,L] 

Upvotes: 2

Related Questions