another mod_rewrite [simple question]

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

another mod_rewrite [simple question]

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Potentially, conditions that split the execution path(s).
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

feyd wrote:Potentially, conditions that split the execution path(s).
Thanks feyd, but I have no clue what your talking about. :oops:
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post 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 ##
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

tecktalkcm0391 wrote:Thanks feyd, but I have no clue what your talking about. :oops:
Vague questions beget even more vague responses. ;)
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What are you using {1} for?
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post 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)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It's not needed if you are only looking for a single digit.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It would likely do that, with or without it. It was superfluous.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post 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
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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).
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post 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?
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post 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.
Post Reply