Reputation: 49
I have index.php file with:
<ul>
<li><a href="/">home</a></li>
<li><a href="index.php?id=1">Offer</a></li>
<li><a href="index.php?id=2">Contact</a></li>
</ul>
<?php
switch ($id) {
case '1':
include 'silnik/oferta.php';
break;
case '2':
include 'silnik/kontakt.php';
break;
default:
echo "<p>brak strony</p>";
break;
}
?>
And i want to change index.php?id=1 to /offer with .htaccess
I have in .htaccess
RewriteEngine On
RewriteRule ^([^/.]+)/?$ /index.php?id=$1
And this doesn't work. Pls help ;)
Upvotes: 0
Views: 153
Reputation: 1667
You have to do 3 things:
change your links: <a href="/offer"></a>
Make case statements in switch in the desired strings
Rewrite:
RewriteEngine On
RewriteRule ^(.+)/?$ /index.php?id=$1
Upvotes: 1
Reputation: 110
RewriteEngine On
RewriteRule ^([0-9]+)/?$ /index.php?id=$1
OR
RewriteEngine On
RewriteRule ^(.*)/?$ /index.php?id=$1
Upvotes: 0