Welcome to WebmasterWorld Guest from 54.158.238.108

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Need help with Mod rewrite code.

     
5:13 pm on Aug 18, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Sept 3, 2005
posts:131
votes: 0


Hello,

I am new in writing mod_rewrite code. Please have a view on my code.

My current URL is -
1) http://mysite.com/bookinfo.php?book=abc

I want it to rewrite it into http://mysite.com/bookinfo/abc

for achiving this i wrote this rule in .htaccess

RewriteRule ^bookinfo/([^/]+)/?$ /bookinfo.php?book=$2 [L]

2)http://mysite.com/books.php?category=abc
I want rewrite it into
http://mysite.com/books/category/abc/

for achiving this i wrote this rule in .htaccess
RewriteRule ^books/([^/]+)/([^/]+)/?$ /books.php?$1=$2 [L]

Means final .htaccess code is -

RewriteEngine On
RewriteRule ^bookinfo/([^/]+)/?$ /bookinfo.php?book=$2 [L]
RewriteRule ^books/([^/]+)/([^/]+)/?$ /books.php?$1=$2 [L]

Please suggest me is my .htaccess file is okay for my purpose or it hase erors.

Warm regards,
Vineet

6:02 pm on Aug 18, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


The first rule should back-reference $1, not $2, Because $1 is undefined in the pattern.

Jim

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members