1
votes

I'm trying to implement a new ReWrite rule on my local dev machine. I have 13 rules set up already, and all work fine (even as of this writing). However, for some reason the newest one is throwing me 500 Internal Server Errors.

The ReWrite rule is:

RewriteRule stuff/public_html/vault/mystuff/view/(.*) /stuff/public_html/vault/mystuff/view/index.php?stuff=$1

RewriteRule stuff/public_html/vault/mystuff/view/(.*)/ /stuff/public_html/vault/mystuff/view/index.php?stuff=$1

Checked my apache logs and got this:

[Thu Jan 13 22:07:43 2011] [error] [client ::1] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary., referer: http://localhost:8888/stuff/public_html/vault/mystuff/all/index.php?curr=7

On the script I am trying to redirect to view/index.php?stuff=$1, there is nothing that even remotely resembles a redirect of any kind. I do have a very, very basic session verifier being called at the top of the landing script, which is as follows:

//Start session
 session_start();

 //Check whether the session variable SESS_MEMBER_ID is present or not
 if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
  header("location: ".$root_http."");
  exit();
 }

However, when I access the page directly, it acts as it should, and there is no redirect. All of my other ReWrite rules and their corresponding landing pages are set up the exact same way.

This is blowing my mind. Any help, PLEASE!?

On suggestion from Marc B I turned on RewriteLog, and came up with this:

::1 - - [13/Jan/2011:23:00:09 --0500] [localhost/sid#807df8][rid#941b38/initial/redir#10] (2) [per-dir /Users/stepheng/Development/] rewrite stuff/public_html/vault/mystuff/view/index.php -> /stuff/public_html/vault/mystuff/view/index.php?stuff=index.php

::1 - - [13/Jan/2011:23:00:09 --0500] [localhost/sid#807df8][rid#941b38/initial/redir#10] (3) split uri=/stuff/public_html/vault/mystuff/view/index.php?stuff=index.php -> uri=/stuff/public_html/vault/mystuff/view/index.php, args=stuff=index.php

::1 - - [13/Jan/2011:23:00:09 --0500] [localhost/sid#807df8][rid#941b38/initial/redir#10] (3) [per-dir /Users/stepheng/Development/] applying pattern 'stuff/public_html/vault/mystuff/view/(.*)/' to uri '/stuff/public_html/vault/mystuff/view/index.php'

::1 - - [13/Jan/2011:23:00:09 --0500] [localhost/sid#807df8][rid#941b38/initial/redir#10] (1) [per-dir /Users/stepheng/Development/] internal redirect with /stuff/public_html/vault/mystuff/view/index.php [INTERNAL REDIRECT]

It looks like it's trying to send the argument ?stuff=index.php, but I don't see how that's possible. Any ideas?

3

3 Answers

5
votes

Turn on rewrite logging:

 RewriteLog /path/to/rewritelog.file
 RewriteLogLevel 9

in your httpd.conf. That'll basically record EVERYTHING the rewrite engine does, and you'll be able to see the exact path a URL took through the system, and most likely why it's doing what looks to be an infinite loop

2
votes

Doesn't that rewrite rule match it's destination? It's going to loop. You need to add the flags that say stop processing rewrite rules at the end:

RewriteRule stuff/public_html/vault/mystuff/view/(.*)/ /stuff/public_html/vault/mystuff/view/index.php?stuff=$1 [L]

0
votes

I'm not sure about the request having this path in it: /stuff/public_html/vault/mystuff/view - where does your document root point to?

Could you post your full apache?

Meantime, try this - it stops redirects if the system matches an existing file or directory, so you should only redirect the once:

RewriteEngine on

RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule stuff/public_html/vault/mystuff/view/(.*)/ /stuff/public_html/vault/mystuff/view/index.php?stuff=$1 [QSA,L]