how to make this?

Discuss practical ways rearrange URLs using mod_rewrite.

how to make this?

Postby visi0n » Thu Sep 18, 2008 3:11 am

Hello! How to make this in mod_rewrite?

Code: Select all
http://site.com/index.php
to
Code: Select all
http://site.com/home/

Code: Select all
http://site.com/index.php?page=2
to
Code: Select all
http://site.com/home/page/2

Code: Select all
http://site.com/movies.php
to
Code: Select all
http://site.com/movies/

Code: Select all
http://site.com/movies.php?page=2
to
Code: Select all
http://site.com/movies/page/2

Code: Select all
http://site.com/movies.php?cat=1
to
Code: Select all
http://site.com/movies/cat/funny

Code: Select all
http://site.com/movies.php?cat=2
to
Code: Select all
http://site.com/movies/cat/jokes

Code: Select all
http://site.com/view.php?id=35
to
Code: Select all
http://site.com/video/35

Code: Select all
http://site.com/search.php?search=word
to
Code: Select all
http://site.com/search/word


Thank you!
visi0n
 
Posts: 5
Joined: Tue Jul 08, 2008 3:45 am

Postby richardk » Fri Sep 19, 2008 7:22 am

/movies.php?cat=1
/movies/cat/funny
/movies.php?cat=2
/movies/cat/jokes

FAQ: How to change a numeric ID into a name/title.

The rest
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# /home/ --> /index.php
RewriteRule ^home/?$ /index.php [QSA,L]

# /home/page/2/ --> /index.php?page=2
RewriteRule ^home/page/([0-9]+)/?$ /index.php?page=$1 [QSA,L]

# /movies/ --> /movies.php
RewriteRule ^movies/?$ /movies.php [QSA,L]

# /movies/ --> /movies.php
RewriteRule ^movies/page/([0-9]+)/?$ /movies.php?page=$1 [QSA,L]

# /video/35/ --> /view.php?id=35
RewriteRule ^video/([0-9]+)/?$ /view.php?id=$1 [QSA,L]

# /search/word/ --> /search.php?search=word
RewriteRule ^search/([^/]+)/?$ /search.php?search=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 31 guests

cron