Home htaccess syntax and rewrite
Reply: 1

htaccess syntax and rewrite

Bartłomiej Giepard
1#
Bartłomiej Giepard Published in 2017-11-12 13:43:20Z

I would like to create a Friendly URL`s.

I have a movie database, every movie has it id, title, year and slug ('title-year').

On the home page, movies are linked like -> example.com/movie.php?id=28

What rules do I have to write to make the address look like my slug? -> example.com/title-year

I was looking for solutions but I do not understand htaccess syntax.

Benjamin Caure
2#
Benjamin Caure Reply to 2017-11-12 13:58:27Z

Assuming movie.php takes slug as parameter instead of id.

example.com/movie.php?slug=pulpfiction-1994

Here is .htaccess code:

RewriteEngine on
RewriteRule   "^/movie/(.+)"  "http://example.com/movie.php?slug=$1"  [R,L]

This should rewrite url

http://example.com/movie/pulpfiction-1994

as

http://example.com/movie.php?slug=pulpfiction-1994
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.337425 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO