Forum Moderators: phranque

Message Too Old, No Replies

rewrite problem

         

askeli

10:41 pm on Aug 23, 2004 (gmt 0)

10+ Year Member



Hi
I have read all through the various guides and searched this excellent site but im still stuck

I am trying to rewrite

http://www.example.com/dir/area/
or
http://www.example.com/dir/2/

to

http://www.example.com/dir/index.php?action=showcat&idcat=2

i have tried

RewriteEngine On
RewriteRule ^dir/([1-9][0-9]*)/ index.php?action=showcat&idcat=$1 [L]

RewriteEngine On
RewriteRule ^dir/(.*)/ index.php?action=showcat&idcat=$1 [L]

with and without

Options FollowSymLinks

and

Rewritebase /dir

or

Rewritebase /

my host does support rewrite, i have various accounts that use it without problems

Any suggestions appreciated

The urls posted keep showing as links so i stopped them, i presume thats correct on this board?

jdMorgan

11:54 pm on Aug 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




Options +FollowSymLinks
RewriteEngine on
RewriteRule ^dir/([^/]+)/ index.php?action=showcat&idcat=$1 [L]

This code, placed in .htaccess in the directory *above* /dir, should work. If not, ask your host to check your config files for the load order of mod_rewrite and php. Php should be loaded *before* mod_rewrite. If not, then mod_rewrite won't run for php files that exist.

Jim

askeli

9:01 am on Aug 24, 2004 (gmt 0)

10+ Year Member



Thanks,

i tried that code but it still wouldnt work, but it works fine if i add

rewritebase /dir

is this ok?

also am i correct in thinking this would be ok for extra page query

RewriteRule ^dir/([^/]+)/([^/]+)/ index.php?action=showcat&idcat=$1&page=$2 [L]

can this ignore images or shall i change the image path out of "dir"

Thank again

jdMorgan

1:18 pm on Aug 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> can this ignore images...?

If needed, add a RewriteCond to ignore images for a single rule, or use mod_rewrite's "Skip" capability to ignore images for multiple RewriteRules:


Options +FollowSymLinks
RewriteEngine on
RewriteBase /dir
RewriteRule \.(gif¦jpe?g¦png¦ico)$ - [NC,S=2]
RewriteRule ^dir/([^/]+)/([^/]+)/ index.php?action=showcat&idcat=$1&page=$2 [L]
RewriteRule ^dir/([^/]+)/ index.php?action=showcat&idcat=$1 [L]

Note that your must edit all the broken pipe "¦" characters above and change them back to solid pipes before use - posting on this board modifies them.

Jim

askeli

1:59 pm on Aug 24, 2004 (gmt 0)

10+ Year Member



that works perfect thank you very much

askeli

11:03 pm on Aug 27, 2004 (gmt 0)

10+ Year Member



Hi

Please help, i need to change this rewrite around so it ignores a directory:

RewriteEngine on
RewriteBase /dir
RewriteRule \.(gif¦jpe?g¦png¦ico)$ - [NC,S=2]
RewriteRule ^dir/([^/]+)/([^/]+)/ index.php?action=showcat&idcat=$1&page=$2 [L]
RewriteRule ^dir/([^/]+)/ index.php?action=showcat&idcat=$1 [L]

i need it to ignore

http://www.example.com/dir/admin/

Many Thanks

jdMorgan

12:48 am on Aug 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just add another rule at the beginning, looking for the directory path you want to exclude, and skipping the other three rules [S=3] if you find it.

The links in our charter [webmasterworld.com] may be helpful.

Jim