Forum Moderators: phranque

Message Too Old, No Replies

repeated doubts : Making Dynamic Web Site Se Friendly

mod_rewrite problem

         

AjiNIMC

4:39 pm on Oct 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

I want to make widgets.com/nimc/gallery/categories.php?cat_id=1 search engine friendly so I tried
like
widgets.com/nimc/gallery/categories1.php

So I tried

RewriteEngine on
RewriteBase /
RewriteRule ^categoriesid([^.]+).* /categories.php?cat_id=$1
[T=application/x-httpd-php]
and some combinations

but it didnt work, I know this must have been discussed over and over, I just need a simple answer to start off, can someone please tell me how can I do that. Please help me , your suggestion will be highly appreciated.

Thanks
AjiNIMC

jdMorgan

5:02 pm on Oct 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> but it didnt work

Please tell us *how* it didn't work. There are many possibilities here, and this is not enough information.

What went wrong?
If you got a server error, what did the error log say?
*Where* did you put the file with this code in it?

Jim

AjiNIMC

5:57 pm on Oct 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I put this file in the same directory where we have categories.php , nothing happened the urls(with?) remained same. Moreover after sometime I saw my site is not accessable so I deleted all .htaccess files and cleared the cache, after which the site worked.

Thanks
AjiNIMC

jdMorgan

6:00 pm on Oct 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Moreover after sometime I saw my site is not accessable

What did your server error log say?

Jim

encyclo

6:02 pm on Oct 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You also have ot make the appropriate alterations to your script or CMS to make it generate and use the new URL structure: the mod_rewrite rules alone won't make that change. All that mod_rewrite does is transparently rewrite the request into something the CMS will understand.

AjiNIMC

1:11 am on Oct 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What did your server error log say?

Jim

Jim, I havent checked the server error log at that time, next time I do it I will check the errors too.

You also have ot make the appropriate alterations to your script or CMS to make it generate and use the new URL structure: the mod_rewrite rules alone won't make that change. All that mod_rewrite does is transparently rewrite the request into something the CMS will understand.

encyclo

encyclo, I think I am missing this section of work. What kind of alteration is requirement? At what level should I use it? Do I need to run .htaccess files to see the changes?

Thanks Jim and encyclo for help , looking forward to learn more on this issue.

Regards
AjiNIMC

jdMorgan

3:47 am on Oct 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



On the pages where your scripts output html links, change those links to be static:

<? echo "<a href=\"http://widgets.com/nimc/gallery/categories1.php\">Click to see cat #1</a>"; ?>

Then your visitors will click on that link (or a spider will find it).

This results in a request to your server for "http://widgets.com/nimc/gallery/categories1.php"

mod_rewrite receives that request when it arrives at your server, and changes it into an internal request for "/nimc/gallery/categories.php?cat_id=1"

This runs your script again with the correct "cat=1" parameter.

Jim