Jump to content

php mod_rewrite


Giddy Rob

Recommended Posts

Hey,

 

I need to change the url so that "www.website.com/item.php?id=1504" will read something more user friendly and better seo. I've heard you do it with a mod_rewrite, but have never done this before so was wondering if someone could show me how?

 

it would be nice if I could output "www.website.com/newstitle_1504.html" where newstitle is the title of the news item being displayed ie this will be different for each article

 

Example would be great :)

 

Cheers :)

Link to comment
https://forums.phpfreaks.com/topic/212341-php-mod_rewrite/
Share on other sites

You change all the links on your site so that they link to the 'pretty' version. Then use something like the following...

 

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^[a-zA-Z0-9-]+_([0-9]+)\.html /item.php?id=$1
</IfModule>

Link to comment
https://forums.phpfreaks.com/topic/212341-php-mod_rewrite/#findComment-1106486
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.