How to rewrite url from id to slug - .htaccess

I am developing a site and the products displayed on site contains url like
product details page -->
mysite.com/jeans/details.php?id=1
I want to convert it to
mysite.com/jeans/details.php?slug.php
slug = new-jeans-america
I want to convert it to
mysite.com/jeans/details.php?new-jeans-america.php
How can I do this ?? Can anyone suggest an htaccess rewrite code ?
I am really new to htaccess .

Related

Redirect /category/item/id-title.html to /category/title using .htaccess

If I have the following old links: example.com/category/item/id-tile.html
how can I redirect them to example.com/category/title
Category changes based on category, item is static, id and title change also. I tried to figure a way through .htaccess, but I don't know how do deal with the id-title thing.

Old link structure to new url structure

We have our own CMS, and having some vacancies website's. Now the issue is, for SEO we've changed the page, where the vacacies are showed on, now google says 300 vacancies can't be found.
I'm asking for your help, since i dont want to changes 300 urls handy..
What i have here is the next url :
website.html/vacatures/vacancieitem/289-docent-duits-1e-graad.html
website.html/vacatures/vacancieitem/245-docent-wiskunde-1e-graad.html
Needs to go to the new url
website.html/onderwijsvacatures/vacancieitem/289-docent-duits-1e-graad.html
website.html/onderwijsvacatures/onderwijsvacatures/245-docent-wiskunde-1e-graad.html
and so go onn
You can use the following redirect in your htaccess :
Redirect 301 /vacatures/ /onderwijsvacatures/

Codeigniter URL rewrite --- Something strange

I just re-writed using htaccess ( with that I just removed the index.php part )
I just got a URL like this
http://localhost/mvc/movies/movie/3237-Movie-name-here
where
mvc - this root folder
movies - controller
movie - view
3237- Query string for getting from DB ( pk)
Movie-name - for SEO URL
with this I can get the movie details with pk 3237
Now I just need to rewrite this url to ( using htaccess )
http://localhost/mvc/movie/3237-Movie-name-here
Please help
Thanks
You can use CODEIGNITER Routing. Described in here http://codeigniter.com/user_guide/general/routing.html
In your case $route['mvc/movies/([:num)/(:any)'] = "mvc/movie/$1-$2";

Rewrite my url for generating seo friendly url

I am trying to rewrite my url for generating the seo friendly url. My original url is something like
video_play.php?cat=1?author=3?video=4
where
"cat=1" is represents my category and 1 is id of my category name like song,movie etc..
"author=3" 3 is the id of singer.
"video=4" 4 is the id of track being played currently...
I want to make this url some thing like video_play/song/artistname/songtitle.html
I am trying this code in .htaccess if any one can help me.. Thanks in advance...
RewriteRule /author/(.*)/cate/(.*) video_play.php?author=$1&cate=$2
Try this instead:
RewriteRule /author/([^\.]*)/cate/([^\.]*) video_play.php?author=$1&cate=$2

Query String Redirection using .htaccess

I am converting a static HTML website to a CMS.
The images folder is conflicting with a category name.
So, I would like to redirect all images in HOWTO directory like :
http://yourdomain.com/howto/images/someimage.jpg
to something like :
http://yourdomain.com/howto_imgs/images/someimage.jpg
I only want to change the image location and redirect old image URL links so they are displayed.
Any help would be much appreciated.
RewriteRule ^howto/images/(.*)$ howto_imgs/images/$1 [R=301,L]

Resources