Forum Moderators: phranque

Message Too Old, No Replies

search engine friendly URL with database

search engine .htaccess file rewrite function

         

mianriz

7:40 pm on Jun 26, 2005 (gmt 0)

10+ Year Member



Hi Programmers!
I want to change my database links into .html links, I read on net about .htaccess file that we can change our database link into simple statis links useing rewirte engine commands. please sort out my problem my links shows as http://www.example.com/cat_sell.php?cid=27

in .htaccess file i use this method
RewriteEngine on
RewriteRule ^cat_sell(.*).html$ cat_sell.php?cid=$1

but its is not working please check and give me solution

I am waiting your quick responce

mianriz

[edited by: ergophobe at 10:07 pm (utc) on June 26, 2005]
[edit reason] URL exemplified as per Usage Agreement and forum charter [/edit]

lobo235

3:18 pm on Jun 27, 2005 (gmt 0)

10+ Year Member



Try adding RewriteBase and get rid of the $ after ^cat_sell(.*).html so you'd end up with the following:

RewriteEngine on
RewriteBase /
RewriteRule ^cat_sell(.*).html cat_sell.php?cid=$1

Let me know if that does the trick for you.

jdMorgan

10:21 pm on Jul 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mianriz,

Welcome to WebmasterWorld!

You must first change the URLs on your pages from unfriendly to friendly -- This can be done either by changing the database or by using (for example) preg_replace on php pages. Once a visitor or search engine "clicks on" a friendly link, a friendly URL request is sent to your server. You then use mod_rewrite to change the friendly URL back into the "unfriendly" form needed to invoke your database access script (cat_sell.php). Your .htaccess code above appears to be almost correct, so all you need to do now is to fix the URLs on your pages.


RewriteRule ^cat_sell([^.]+)\.html$ /cat_sell.php?cid=$1 [L]

Jim