Forum Moderators: phranque

Message Too Old, No Replies

mod_rewite - how to debug generically

mod_rewite

         

ant1

7:03 pm on Mar 18, 2006 (gmt 0)

10+ Year Member



I have decided to start using mod_rewrite and have read the manual. As my site is already getting a lot of traffic I cannot play around with it on the production box. So here is ideally what i would like to do:

Have a subdirectory called testredirect

within it I would like to have a .htaccess file that would look like the following:

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^search/(.+) user_display_search.php?app_id=22?ash_id=$1
RewriteRule ^show/(.+) user_display_text.php?app_id=22?doc_type=$1
RewriteRule ^form/(.+) user_display_form.php?app_id=22?af_id=$1

ideally I want to then go:
www.domain.com/testredirect/search/123

which will go to
www.domain.com/user_display_search.php?app_id=22/ash_id=123

the thing is that I guess I have to have a file I test inthe /testredirect/ folder which is different to the live one.

In either case I am not sure how to:
a- debug a file
b- have a safe setup to test the file that will then work on my prod environment.

thank you for any hints and tips you can provide.

thank you very much in advance.

Ant1

jdMorgan

7:53 pm on Mar 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ant1,

Weclome to WebmasterWorld!

If I understand your set-up, it's fairly simple:

1) Server-root the substitution URLs (precede them with "/").
2) Use the [L] flag on each rule unless you have a specific reason not to.


RewriteRule ^search/(.+)$ /user_display_search.php?app_id=22?ash_id=$1 [L]
RewriteRule ^show/(.+)$ /user_display_text.php?app_id=22?doc_type=$1 [L]
RewriteRule ^form/(.+)$ /user_display_form.php?app_id=22?af_id=$1 [L]

Jim

ant1

4:37 pm on Mar 24, 2006 (gmt 0)

10+ Year Member



Thank you very much for that and I have almost what I want:

my current dir structure is:

www - all my php code
www/css - all my stylesheets
www/img - all my images
www/testredirect - where i have my .htaccess for testing

Now when I type

www.mysite.com/testredirect/search/22

all the links go to:

www.mysite.com/testredirect/search/user_display_search.php?app_id=22?ash_id=1

when what I would like is for all the displayed links on the page to be:

www.mysite.com/user_display_search.php?app_id=22?ash_id=1

So effectively I only did one re-direct. I know that moving the .htaccess into www will fix this but I would like to be able to test the entire file thoroughly before putting it into my production environment.

Any further suggestions?

Thank you very much again for the previous bit of help and in advance for any help on this one.

jdMorgan

1:27 am on Mar 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you really want to do that detailed level of testing, grab an old PC and install Apache on it. Anything of the Pentium II - 400MHz class or above should be entierly sufficient for a test server.

Jim