Page 1 of 2
another mod_rewrite [simple question]
Posted: Tue Jun 19, 2007 9:36 pm
by tecktalkcm0391
If I have a page at site.com/checkout.php and I have mod_rewrite allowing site.com/checkout and I want to do another mod_rewrite to allow site.com/checkout/1 (or site.com/checkout?step=1 or site.com/checkout.php?site=1) how can I do it without getting a 500 error.
Posted: Tue Jun 19, 2007 9:41 pm
by feyd
Potentially, conditions that split the execution path(s).
Posted: Tue Jun 19, 2007 10:45 pm
by tecktalkcm0391
feyd wrote:Potentially, conditions that split the execution path(s).
Thanks feyd, but I have no clue what your talking about.

Posted: Tue Jun 19, 2007 10:54 pm
by Zoxive
Can you show what you have so far?
Code: Select all
RewriteRule ^checkout/$ checkout.php
RewriteRule ^checkout/([0-9]+)$ checkout.php?step=$1
## Very Basic ##
Posted: Tue Jun 19, 2007 10:57 pm
by feyd
tecktalkcm0391 wrote:Thanks feyd, but I have no clue what your talking about.

Vague questions beget even more vague responses.

Posted: Tue Jun 19, 2007 11:04 pm
by tecktalkcm0391
What I have so far is...
Code: Select all
#Allows all urls for .php to be /page
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
#Hade this but just saw the error...
RewriteRule checkout/([0-9]+{1})$ /checkout.php?step=$1
#changed to this now...
RewriteRule checkout/([0-9]{1})$ /checkout.php?step=$1
#but it still doesn't work?
Posted: Tue Jun 19, 2007 11:25 pm
by feyd
What are you using {1} for?
Posted: Tue Jun 19, 2007 11:43 pm
by tecktalkcm0391
feyd wrote:What are you using {1} for?
Because I only want 1 digit numbers. so it can only go step 1-9 (well technically 0-9)
Posted: Tue Jun 19, 2007 11:53 pm
by feyd
It's not needed if you are only looking for a single digit.
Posted: Wed Jun 20, 2007 12:08 am
by tecktalkcm0391
feyd wrote:It's not needed if you are only looking for a single digit.
Ok, but how come when i got to site.com/checkout/2 it gives me a 500?
Posted: Wed Jun 20, 2007 12:30 am
by feyd
It would likely do that, with or without it. It was superfluous.
Posted: Wed Jun 20, 2007 12:40 am
by tecktalkcm0391
feyd wrote:It would likely do that, with or without it. It was superfluous.
feyd i'm no getting you today. maybe cause its so late.

I'm still getting the 500 error with:
Code: Select all
#Allows all urls for .php to be /page
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
RewriteRule checkout/([0-9])$ /checkout.php?step=$1
Posted: Wed Jun 20, 2007 5:16 am
by superdezign
Try starting the rule with a '/', and be sure that you've set the RewriteBase.
Check your error log to see if the problem is the regex, or if you're referencing an incorrect file (due to the lack of RewriteBase, you'll oftentimes be in the wrong directory and not know).
Posted: Wed Jun 20, 2007 9:44 am
by tecktalkcm0391
superdezign wrote:Try starting the rule with a '/', and be sure that you've set the RewriteBase.
Check your error log to see if the problem is the regex, or if you're referencing an incorrect file (due to the lack of RewriteBase, you'll oftentimes be in the wrong directory and not know).
How can I get to the error log when I'm on a shared server, can I change it to a file I can access?
Posted: Wed Jun 20, 2007 10:26 am
by Zoxive
tecktalkcm0391 wrote:superdezign wrote:Try starting the rule with a '/', and be sure that you've set the RewriteBase.
Check your error log to see if the problem is the regex, or if you're referencing an incorrect file (due to the lack of RewriteBase, you'll oftentimes be in the wrong directory and not know).
How can I get to the error log when I'm on a shared server, can I change it to a file I can access?
Most shared servers have it in their cpanel.