I\'m trying to write an .htaccess file that will make my URLs more attractive to search engines. I know basically how to do this, but I\'m wondering how I could do this dyna
At the moment you're wondering how to convert your ugly URL (e.g. /view.php?mode=prod&id=1234
) into a pretty URL (e.g. /products/product-title
). Start looking at this the other way around.
What you want is someone typing /products/product-title
to actually take them to the page that can be accessed by /view.php?mode=prod&id=1234
.
i.e. your rule could be as follows:
RewriteRule ^products/([A-Za-z0-9-])/?$ /view.php?mode=prod&title=$1
Then in view.php do a lookup based on the title
to find the id
. Then carry on as normal.