Cleaning simple php urls.

I have a dynamic website in which I’m learning to clean the url’s. I know mod_rewrite is working as I ran a test on it, to prove that it’s working. The url’s that I want cleaned look as follow :

http://mysite.com/?action=Page&pageId=3
[color=black] and other url’s like this[/color]
http://mysite.com/?action=Pages

I want them to look like this :

http://mysite.com/Page/3/
[color=black] and [/color]
http://mysite.com/Pages/

I’m trying to get my head around to understanding the rewrite rules. Here’s the attempt I have made as well as other attempts :

RewriteEngine on
RewriteRule ^http://mysite.com/([^/]+)/?$ ?action=Page&pageId=$1 [L]

No success, so here I am looking for help as this will help me to understand how to clean my url’s. Thanks a bunch in advance for all those who give assistance.

I fixed this url :

http://mysite.com/?action=Page&pageId=3

                  to

http://mysite.com/Pages/Page/3

         using this

RewriteRule ^Pages/Page/([^/]+)/?$ ?action=Page&pageId=$1 [L]

I’m still trying to change the other url :

http://mysite.com/?action=Pages

             to

http://mysite.com/Pages/

I’m failing at all approaches. Again thanks for all help on this.

Would it not just be something like this? I’m not very good with mod_rewrite sorry :slight_smile:

RewriteRule ^Pages/(.*)$ ?action=Pages [L]

This was it. Thanks again m@tt, as always your good help here on this forum. :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service