Having htaccess issues

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule .*$ index.php?/$1 [L]

this is sending my server into an infinite loop according to the error log. max internal redirects and then it kicks out 500 error. i did not write this, it came as part of a script and i’m not sure exactly how to fix it. any ideas?

Well… I did spot one issue. It looks like you’re missing parentheses.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\\.php|robots\\.txt)
RewriteRule [COLOR="#FF0000"][SIZE=4]([/SIZE][/COLOR].*$[COLOR="#FF0000"][SIZE=4])[/SIZE][/COLOR] index.php?/$1 [L]

Otherwise, $1 will always be blank. However, it doesn’t look like this would causes an infinite loop.

hmmm. i’ve been pulling out my hair trying to figure this out all day, and i finally got it i think.


RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\\.php|robots\\.txt)
RewriteRule .*$ index.php?/$1 [L]


for some reason the RewriteBase seems to have fixed it. all is working well as of now. don’t understand why, but don’t need to :wink:

jm,

Nope, you’ve not created $1 and are using it in the RewriteCond and RewriteRule.

Either create an atom with your EVERYTHING atom or use the {REQUEST_URI} as follows:


RewriteEngine On
[COLOR="#FF0000"]# RewriteBase / - DELETE as this serves no useful purpose.[/COLOR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
[COLOR="#FF0000"]# RewriteCond $1 !^(index\\.php|robots\\.txt) - Assuming you have index.php and robots.txt files, this is already handled by the !-f above[/COLOR]
RewriteRule ^(.*)$ index.php?[COLOR="#FF0000"]/[/COLOR]$1 [L] # OR
[COLOR="#A9A9A9"]# RewriteRule .? index.php?{REQUEST_URI} [L] - untested; this may capture the / between the domain name and URI so use R=301 to test[/COLOR]

You might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It’s helped may members and should help you, too.

Regards,

DK