I have to create Search engine optimization-friendly web addresses for my website. I discovered I'm able to use .htaccess to rewrite them. And So I attempted this:

> http://www.domain.com/page/1/mypage
> http://www.domain.com/user/2/myuser
> http://www.domain.com/help/3/myhelp

Now i'm tied to a typical rule and that i do not understand Ant to redirect traffic in line with the title from the page:

I personally use:

RewriteEngine ON
RewriteRule ^(.*)$ page.php?page=$1

Then during my PHP I do not obtain the page properly, I recieve the file that is wrong.

How do i fix this?

Here's what you ought to do:

RewriteEngine On
RewriteBase /
RewriteRule ^([a-z_\-]+)/([0-9]+)/([a-z_\-]+)/?$ page.php?page=$1&id=$2&name=$3 [NC,L]

NC (or nocase) Helps make the test situation-insensitive, A = a

L (or last) Last rule. Steer clear of the spinning process here and do not apply anymore rewrite rules

You will get more information at http://httpd.apache.org/docs/current/mod/mod_rewrite.html

Make certain rewrite engine is on first.

The very first rule enables you to definitely take away the .php from given filenames, and also the second could be for implementing the Web addresses you provided ( but needing to write a brand new rule for every Link to course )

RewriteEngine on

RewriteRule ^(mypage|contact)/?$ $1.php?%{QUERY_STRING}/ [PT]

# so this would be page.php?id=1&page=mypage
# in your case domain.com/page/1/mypace
RewriteRule ^ page/([^/\.]+)/id/([^/\.]+)/?$ page.php?id=$1&page=$2 [L]