Forum Moderators: phranque

Message Too Old, No Replies

how can i mod rewrite my site

mod rewrite php site

         

secret27

9:14 pm on Aug 10, 2005 (gmt 0)

10+ Year Member



i am trying to Mod_rewrite my site from php to html
but im new and need some help to find the correct codes to put .htaccess

mydomain.com/index.php

my main categories :

mydomain.com/list.php?pagenum=0&catid=2
to
mydomain.com/list.php?pagenum=0&catid=19

in the category 19 sample url

mydomain.com/fikra.php?id=701&listtype=4&catid=19
mydomain.com/fikra.php?id=696&listtype=4&catid=19

can anyone help me to find the correct Mod_rewrite codes.
Thanks

jdMorgan

1:52 am on Aug 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



secret27,

Welcome to WebmasterWorld!

This search [google.com] should turn up some good threads to get you started with rewriting static to dynamic URLs.

Useful references are cited in our forum charter [webmasterworld.com].

Jim

secret27

11:15 pm on Aug 13, 2005 (gmt 0)

10+ Year Member



#DirectoryIndex index.php
Options FollowSymLinks
RewriteEngine on
#RewriteBase /

# REWRITING THE OTHERS
RewriteRule ^cat(.*).html$ list.php?pagenum=$1&catid=$1 [L]
RewriteRule ^viewfikra(.*).html$ fikra.php?id=$1&listtype=4&catid=$1 [L]

i have try this code,but my site give this error

Forbidden
You do not have permission to access this document.

--------------------------------------------------------------------------------

Web Server at domain.com

jdMorgan

11:29 pm on Aug 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What does your error log say?

Jim

secret27

12:23 am on Aug 14, 2005 (gmt 0)

10+ Year Member



when i type my site adres
that error seen in my index page and i cant connect to my site

jdMorgan

1:52 am on Aug 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Remove the code. Check your server error log. It is a separate log file, usually stored in the same directory as your access log, and sometimes in the same directory as your "stats" files.

Jim

secret27

2:26 am on Aug 14, 2005 (gmt 0)

10+ Year Member



i have checked my error log,but there isnt any error.
i have try it with the code in my .htaccess file,but the error log didnt write anything

secret27

3:45 pm on Aug 15, 2005 (gmt 0)

10+ Year Member



#DirectoryIndex index.php
Options FollowSymLinks
RewriteEngine on
#RewriteBase /
# REWRITING THE OTHERS
RewriteRule category(.*)-(.*)\.htm$ /list.php?pagenum=$1&catid=$2

when i tr this code,i can find

[domain.com...] it work fine
but page numbers dont work now
[domain.com...] isn't show the true page
[domain.com...] isn't show the true page

and the other thing,when i am on index php or category-0-2.htm
my category list give the php urls like as :
list.php?pagenum=0&catid=2
what must i do for change them to
category-0-2.htm
category-0-3.htm
category-0-4.htm
......

jdMorgan

3:57 pm on Aug 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't really see anything wrong with your rule, but the following will be more efficient:

# REWRITING THE OTHERS
RewriteRule ^category([^-]+)-([^-]+)\.htm$ /list.php?pagenum=$1&catid=$2 [L]

Flush your browser cache *every* time you test new code.

and the other thing, when i am on index php or category-0-2.htm
my category list give the php urls like as :
list.php?pagenum=0&catid=2
what must i do for change them to
category-0-2.htm
category-0-3.htm
category-0-4.htm

You must change the links on your page, either by editing them, editing your database, or by using something like the php preg_replace directive to make the URLs search engine friendly.

In this way, visitors and robots "see" the friendly URLs, "click" on them, and request a friendly URL from your site. You mod_rewrite rules them change that friendly URL back into a call to your "list.php" script, with the parameters moved from the URL into query string parameters.

Jim

jd01

4:34 pm on Aug 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

The problem is a missing - that is being stored in the first variable:
RewriteRule category(.*)-(.*)\.htm$ /list.php?pagenum=$1&catid=$2

Correction:
RewriteRule category-(.*)-(.*)\.htm$ /list.php?pagenum=$1&catid=$2

Or this:
RewriteRule ^category-([^-]+)-([^-]+)\.htm$ /list.php?pagenum=$1&catid=$2 [L]

Think I have missed one of those myself once or twice...

Justin

Added: The bottom rule is faster =)

secret27

4:28 pm on Aug 16, 2005 (gmt 0)

10+ Year Member



RewriteRule category-(.*)-(.*)\.htm$ /list.php?pagenum=$1&catid=$2
this is what i need thanks a lot :)

can i print the category name as htm
this code make
category-0-1.htm
category-0-2.htm
i will
category1name.htm
category2name.htm

is it possible make that
thanks

secret27

10:36 pm on Sep 12, 2005 (gmt 0)

10+ Year Member



#DirectoryIndex index.php
Options +FollowSymLinks
RewriteEngine on
# REWRITING THE OTHERS

RewriteRule category-(.*)-(.*)\.htm$ /list.php?pagenum=$1&catid=$2 [L]
RewriteRule fikra-(.*)\.htm$ /fikra.php?id=$1 [L]

this codes are true,but what must i do for change the links in index.php
must i put any code to my php scritp? can anyone help me please

jdMorgan

1:07 am on Sep 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> must i put any code to my php script?

Yes, you should change the links in your script so that they appear on your pages in the form that you want.

You can either hand-code each link, or use php preg_replace or string_replace function to modify the links if they come from your database.

Jim

secret27

10:11 am on Sep 16, 2005 (gmt 0)

10+ Year Member



they come from database and i will use php preg_replace or string_replace function

can u suggest a small sample for me please..