Reputation: 83
I'm trying to write a .htaccess file that would enable me to write
sampleurl.com/car.php?car=1&name=Audi-A4
And than it would make the url:
sampleurl.com/cars/Audi-A4/1
my current code is:
RewriteEngine on
RewriteRule ^cars/([0-9][0-9])$ /cars/$1/ [R]
RewriteRule ^cars/([0-9][0-9])$ /cars/$1/ [R]
RewriteRule ^cars/([0-9][0-9])/$ /car.php?car=$1
Are there any ideas how could I make this work?
EDIT:
Both codes work:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ /car.php?name=$1&car=$2 [L]
and
Options -MultiViews
RewriteEngine On
RewriteRule ^cars/([\w-]+)/(\d+)/?$ car.php?car=$2&name=$1 [L,QSA,NC]
but when I open the website, it shows just the page, without linked css file, how can I link the css file to that webpage?
Current CSS Link code:
<link rel="stylesheet" type="text/css" href="style/main.css">
Upvotes: 3
Views: 79
Reputation:
You can write your .htaccess like this
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ /car.php?name=$1&car=$2 [L]
Upvotes: 4
Reputation: 784968
You can use this rule in your site root .htaccess:
Options -MultiViews
RewriteEngine On
RewriteRule ^cars/([\w-]+)/(\d+)/?$ car.php?car=$2&name=$1 [L,QSA,NC]
Upvotes: 1