Forum Moderators: phranque
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
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]
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.