Hittade en bra tråd i WMW (webmasterworld.com/forum92/3527.htm):
Citat:
In a nutshell:
# Link on the page: BMW (use php preg_replace to create this link if you can't change the underlying database)
# Visitor clicks the link, browser requests http://www.example.com/bmw-32-12
# Request arrives at your server.
# Mod_rewrite (assuming it's in httpd.conf) applies the following rule:
RewriteRule ^/bmw-([0-9]+)-([0-9]+)$ /bmw.php?cat=$1&id=$2 [L]
# Mod_rewrite modifies the local URL-path to /bmw.php?cat=32&id=12 and activates the bmw.php script.
# /bmw.php, using the cat and id parameters, produces the correct page with more links like step 1.
# Cycle repeats.
If you are interested in SEO aspects, use hyphens, not underscores, and certainly not commas (they are restricted characters and will have to be encoded as '%2C', which is ugly).
To prevent your 'unfriendly' URLs from being indexed, or to replace those previously indexed, add another rule:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /bmw\.php\?cat=([0-9]+)&id=([0-9]+)$
RewriteRule ^/bmw\.php$ http://www.example.com/bmw-%1-%2 [R=301,L]
|
Innan jag börjar sätta mig in i och göra detta. Finns det någon här som har gjort liknande? Några tips? Funkar ovanstående?
Tack.