skip to Main Content

I’m trying to make my own CMS and at this moment I’m looking to get clean my URLs, but I can’t erase the first GET parameter and leave just the second.
The unique thing that I did was to remove the extension file name with another .htaccess condition, but I can’t solve this problem.

An example:

www.mysite.com/posts?id=2&title=The%20PostTitle

To:

www.mysite.com/posts/The%20PostTitle

Can someone help me?

3

Answers


  1. Chosen as BEST ANSWER

    I found a video tutorial that can be useful to everyone who is trying to understand how to use .htaccess files. I hope it will be very helpful on your own projects. Semantic URL htaccess Tutorial SEO Friendly Clean Links

    Thank you to everyone who tried to help me!

    To the spanish speakers, you can read something about regular expresions (regex). This is the link: Reemplazar cadenas y caracteres de un string.


  2. Try this

    RewriteEngine on
    RewriteRule ^posts/([a-zA-Z0-9_-]+)/?$ "posts?title=$1&id=$2" [NC]
    
    Login or Signup to reply.
  3. Try this. Its not tested.

    RewriteCond %{REQUEST_URI} /posts?id=(d+)&title=(.*)(&*.=.*){0,1}$ [NC]
    RewriteRule .* http://www.example.com/posts/[%2]/?id=%1&%3
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search