SEO Friendly URL Rewrites

I've seen lots of other questions and demos out there, but I'm still a little fuzzy on this business of search engine friendly URLs.

If I have a url like this:

How can I make this search engine friendly, without messing up the dynamic variables passed to my website, which determines content?

Also, is there a generic set of .htaccess rules that would work for this?  I have several sites that use this simple structure of

And I've seen some sites that look more like this: (no .php)
LVL 12
Who is Participating?
wassa_rConnect With a Mentor Commented:
No, it changes an url like /section/pagename-8 to /pagename/doesntmatter-8 to /pagename.php?id=8. It does not take extra folder depths in account. If you wan't to do things as extensive as that you might wan't to consider doing it in PHP itself.
If you don't want to mess up the dynamic variables that popuplate the content, you'll have to pass the id in the new URL as well.

So, you could rewrite it from /services.php?id=1 to

A general rule for rewriting something like pageName.php?id=1 to pagename/asdf-1 could look like this:
RewriteRule ^([^\/]+)\/.+\-([0-9]+)$ /$1.php?id=$2 [L]

It takes the part before the / as the sectionname ( .php ), the second part is the pagename and page id.

so /asdf/sadfas-1 would go to asdf.php?id=1.

Hope this helps.
rowejdAuthor Commented:
This doesn't seem to be working.

RewriteEngine on
RewriteRule ^([^\/]+)\/.+\-([0-9]+)$ /$1.php?id=$2 [L]

Doesn't change my url:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.