Forum Moderators: phranque

Message Too Old, No Replies

Unable to RewriteRule

'http://myproject/foo/438' problem

         

guarriman

3:39 pm on Aug 19, 2005 (gmt 0)

10+ Year Member



Hi.

I want to make:
[myproject...]
serve
[myproject...]

And
[myproject...]
serve
[myproject...]

So I inserted in my 'httpd.conf':
----------------------------
<Directory "/home/myproject/htdocs">
Options Indexes FollowSymLinks
Order Allow,Deny
Allow from 127.0.0.1
Allow from all
php_flag allow_url_fopen 1
php_flag magic_quotes_gpc 0
RewriteEngine on
RewriteOptions MaxRedirects=15
RewriteCond %{REQUEST_FILENAME}!-d
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^(.*)$ /$1.php [L,QSA]
RewriteRule /foo/^(.*)$ /foo.php?id=$1 [L,QSA]
</Directory>
------------------------------

But, when accessing 'http://myproject/foo/438', I get a '500 Internal Server
Error' on my browser and this error on my logs:
------------------
[Fri Aug 19 11:24:46 2005] [error] [client 192.168.2.101] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
-------------------

'http://myproject/whatever' works fine.

What am I doing wrong? Regards.

jd01

6:07 am on Aug 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RewriteCond %{REQUEST_FILENAME}!-d
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^(.*)$ /$1.php [L,QSA]
RewriteRule /foo/^(.*)$ /foo.php?id=$1 [L,QSA]

Not exactly sure what you are trying to accomplish with the checks to see if a file or directory does not exist on the first rule? If you are only rewriting a couple of files, then better to use a match for them (IOW name). The syntax of the second appears incorrect...

Maybe I am missing something?

I would try:

RewriteRule ^/whatever$ whatever.php [L]
RewriteRule ^/foo/(.*) foo.php?id=$1 [L]

The preceding / on the right side of the rule should be present in the .htaccess, but is not necessary in the httpd.conf.

The QSA (Query String Append) should also not be necessary - It should only be needed when adding information to an existing query string.

Hope this helps.

Justin