Code .htaccess:
You should use
- Code: Select all
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.nl$ [NC]
RewriteRule ^(.*)$ http://www.example.nl/$1 [R=301,L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /product.php?categorie=$1&subcategorie=$2&slug=$3 [QSA,L]
1. Images wont show up aymore. What should I add or change in the .htaccess for this?
Read the FAQ i previously linked to. You do not add anything to your .htaccess file, you add a <base> to your HTML.
2. The URL still contains %20 (spaces) which I want to convert to dashes. When I manually link with dashes it does work, but there is no way to do this automatcally now because the variables in my database d not contain hyphens.
Use PHP to do a str_replace() when 0outputting the links and a str_replace on the variable from the URL.
- Code: Select all
<a href="http://www.mysite.com/<?php echo str_replace(array('%20', ' '), '-', $row_Recordset1['categorie']) . "/" . str_replace(array('%20', ' '), '-', $row_Recordset1['subcategorie']) . "/" . str_replace(array('%20', ' '), '-', $row_Recordset1['slug']) . "/"; ?>
Then add the folloign to the beginning of product.php
- Code: Select all
<?php
// Replace dashes with spaces.
if(isset($_GET['categorie']))
{
$_GET['categorie'] = str_replace('-', ' ', $_GET['categorie']);
}
// Replace dashes with spaces.
if(isset($_GET['subcategorie']))
{
$_GET['subcategorie'] = str_replace('-', ' ', $_GET['subcategorie']);
}
// Replace dashes with spaces.
if(isset($_GET['slug']))
{
$_GET['slug'] = str_replace('-', ' ', $_GET['slug']);
}
3. How do I rewrite the above given URL so that it automatically replaces dashes with hyphens? I want to do this so that the code of my page also contains the exact same URL with hyphens as does the rewritten URL of problem #2.
I don't understand.