Dynamic url to SEO Friendly urls using Apace Mod_rewrite

I would like to know how to convert a dynamic urls to more seo friendly urls using Apache mod rewrite.

E.g of dynamic urls
* http://www.domain.com/?p=portfolio
* http://www.domain.com/?p=contact
* http://www.domain.com/?p=portfolio&pid=52&page=thumbs
* http://www.domain.com/?p=portfolio&pid=52&page=photos&photoid=754
* http://www.domain.com/?p=portfolio&pid=52&page=photos&photoid=754&pages=2


* http://www.domain.com/portfolio
* http://www.domain.com/contact
* http://www.domain.com/portfolio/sculptor-richard-serra/
* http://www.domain.com/portfolio/sculptor-richard-serra/pages/2/

Thanks for your time.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dushyant SharmaCommented:
you can try like below

Redirect /?p=portfolio  http://mydomain.site/portfolio
Redirect /?p=contact  http://mydomain.site/contact

RedirectMatch ^/?p=([a-zA-Z0-9]*)$  http://mydomain.site/$1

here is some simple reference


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
Hi, Polask.  Just a note... "SEO-friendly URLs" is a misleading concept.  The search engines do not care a bit about what your URL contains.  They look at things like (more or less in order) how many meaningful and important sites link to your site, the HTML <title> tag, the "meta description", the HTML <h1> tag and the text of your page, especially near the top.

A better name for this might be "easy to remember URLs" because people might remember the sculptor's name before they would remember pid=52.

I would recommend that you implement a 404 handler, and connect it to a search page.  That way, when I come to your site with a typo like this...

... your site can respond with a page that says something like, "No sculptor-richard-sierra here.  Do you want to see http://www.domain.com/portfolio/sculptor-richard-serra/"
xposegrafixAuthor Commented:
Not very helpful.
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

Ray PaseurCommented:
What was un-helpful?  I thought the question was well answered.  Were you not able to get what you wanted?
xposegrafixAuthor Commented:
Cause it didn't work.
Ray PaseurCommented:
Uhh, that would indicate to me that you might want to post a note about that in the question thread here to get clarifying information?  "Didn't work" does not give us much to go on.
xposegrafixAuthor Commented:
ok, thank you
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.