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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.