Forum Moderators: phranque
If you discard the content of $1, $2 and $3, and only use the number in $4 as a key to pull the record from the database, I could link to www.example.com/useless_junk_product_26.html and the same page would display.
You really do need to take the other parts and validate them against the real article title as stored in the database - and then either send a 404 Not Found page, or redirect the user to the correct URL for that content.
RewriteRule cannot see the leading / on a URL request. That's the main reason your rule does not work.
Be aware that your rule will also respond to both www and non-www requests unless you take action to redirect all non-www URL requests over to the www version of the URL. This redirect must go before the rewrite in the .htaccess file.
[___.com...]
[___.com...]
RewriteEngine On
RewriteRule ^/([0-9]+)_([a-z]+)_([a-z]+)_([0-9]+).html$ /vehicle.php?id=$4&year=$1&make=$2&model=$3
<?php some php code that checks to see if the year, make and model match the actual values for the id ?>
[edited by: matthewamzn at 7:36 pm (utc) on Mar. 25, 2009]
I looked it up. Do you mean something like this?
RewriteEngine On
RewriteCond %{HTTP_HOST} ^_______\.com [NC]
RewriteRule ^(.*) [_______.com...] [R=301,L]
RewriteRule ^([0-9]+)_([a-z]+)_([a-z]+)_([0-9]+).html$ /vehicle.php?id=$4&year=$1&make=$2&model=$3
RewriteEngine On
#
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
RewriteRule ^([0-9]+)_([a-z]+)_([a-z]+)_([0-9]+)\.html$ /vehicle.php?id=$4&year=$1&make=$2&model=$3 [L]
[edited by: jdMorgan at 1:11 am (utc) on Mar. 26, 2009]
_____.com/path/page.php
becomes
[_____.com...]
Shouldn't the * tell it to append the entire path?
RewriteEngine On
RewriteCond %{HTTP_HOST} ^_____.com [NC]
RewriteRule ^(.*)$ [_____.com...] [R=301,L]
RewriteRule ^([0-9]+)_([a-z]+)_([a-z]+)_([0-9]+).html$ /vehicle.php?id=$4&year=$1&make=$2&model=$3