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
intellivision
Forum Commoner
Posts: 83 Joined: Mon Aug 22, 2005 1:25 am
Location: Orbit
Post
by intellivision » Mon Jan 16, 2006 12:12 pm
I'm trying to rewrite
domain.com/product_reviews.php?mode=1&id=44
into
domain.com/product_reviews/mode/1/id/44/
I'm working in domain.com/.htaccess
I'm getting a "The requested URL /product_reviews/mode/1/id/44/ was not found on this server."
Code: Select all
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L]
Options +FollowSymLinks
RewriteRule product_reviews/mode/(.*)/id/(.*) product_reviews.php?mode=$1&id=$2
RewriteRule product_reviews/mode/(.*)/id/(.*)/ product_reviews.php?mode=$1&id=$2
</IfModule>
What am I doing wrong?
foobar
Forum Regular
Posts: 613 Joined: Wed Sep 28, 2005 10:08 am
Post
by foobar » Mon Jan 16, 2006 1:10 pm
intellivision wrote: I'm trying to rewrite
domain.com/product_reviews.php?mode=1&id=44
into
domain.com/product_reviews/mode/1/id/44/
No you're not. It's the other way around.
First, I'd get rid of all the unnecessary stuff and reformulate the regex pattern:
Code: Select all
RewriteEngine on
#Make webroot working directory
RewriteBase /
#One rule instead of two...
RewriteRule product_reviews/mode/(\d+)/id/(\d+)(/)?$ product_reviews.php?mode=$1&id=$2
That should throw a 500 error if you don't have mod_rewrite installed.
Further, it only allows integers to be passed as mode and id.
If this code works, you can put the Options and your other RewriteRule back in.
intellivision
Forum Commoner
Posts: 83 Joined: Mon Aug 22, 2005 1:25 am
Location: Orbit
Post
by intellivision » Mon Jan 16, 2006 1:36 pm
Thanks.
domain.com/product_reviews/mode/1/id/45/ = 404 error
The following is the entire .htaccess file, and I checked it via ssh/pico to make sure no strange characters are getting in it (none):
Code: Select all
<IfModule mod_rewrite.c>
RewriteEngine on
#Make webroot working directory
RewriteBase /
#One rule instead of two...
RewriteRule product_reviews/mode/(\d+)/id/(\d+)(/)?$ product_reviews.php?mode=$1&id=$2
</IfModule>
From my host -- Dreamhost:
We run a default apache installation, so
anything that works there, should work here.
So I'm sure the module is there. Here's more proof:
http://wiki.dreamhost.com/index.php/Mod_rewrite .
foobar
Forum Regular
Posts: 613 Joined: Wed Sep 28, 2005 10:08 am
Post
by foobar » Mon Jan 16, 2006 2:01 pm
Have you tried getting rid of the <IfModule> tags?
Also, can you post where on the server relative to the webroot your account resides?
(This can be done via getcwd() in a PHP script.)
Furthermore, can you post what exactly is in your root directory? Such as a screenshot of the directory listing.
intellivision
Forum Commoner
Posts: 83 Joined: Mon Aug 22, 2005 1:25 am
Location: Orbit
Post
by intellivision » Mon Jan 16, 2006 2:29 pm
Tags removed, no change.
results in nothing but the word 'test', in both screen and source. Grrr. I have no idea where the webserver is in relation to my shared hosting root directory.
Here's the root directory shot:
foobar
Forum Regular
Posts: 613 Joined: Wed Sep 28, 2005 10:08 am
Post
by foobar » Mon Jan 16, 2006 3:12 pm
intellivision wrote:
results in nothing but the word 'test', in both screen and source. Grrr. I have no idea where the webserver is in relation to my shared hosting root directory.
Try this instead:
You might want to do the following change in the .htaccess file:
intellivision
Forum Commoner
Posts: 83 Joined: Mon Aug 22, 2005 1:25 am
Location: Orbit
Post
by intellivision » Mon Jan 16, 2006 3:48 pm
D'oh! Result:
/home/.eamonblendersybian/matthew1/matthe/domain.com
RewriteBase ./ caused a 500 Internal Server Error on the whole site.
redmonkey
Forum Regular
Posts: 836 Joined: Thu Dec 18, 2003 3:58 pm
Post
by redmonkey » Tue Jan 17, 2006 12:25 am
\d is most likely the culprit, you could try something along the lines of....
Code: Select all
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule product_reviews/mode/([0-9]+)/id/([0-9]+)(/)?$ product_reviews.php?mode=$1&id=$2
</IfModule>
intellivision
Forum Commoner
Posts: 83 Joined: Mon Aug 22, 2005 1:25 am
Location: Orbit
Post
by intellivision » Wed Jan 18, 2006 12:16 am
It works.
Thanks to both of you for your help with this. Much appreciated.