SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    May 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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?

  2. #2
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,148
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Well... I did spot one issue. It looks like you're missing parentheses.

    Code:
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|robots\.txt)
    RewriteRule (.*$) index.php?/$1 [L]
    Otherwise, $1 will always be blank. However, it doesn't look like this would causes an infinite loop.
    "First make it work. Then make it better."

  3. #3
    SitePoint Member
    Join Date
    May 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmmm. i've been pulling out my hair trying to figure this out all day, and i finally got it i think.

    Code:
    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

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,604
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    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:

    Code:
    RewriteEngine On
    # RewriteBase / - DELETE as this serves no useful purpose.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # RewriteCond $1 !^(index\.php|robots\.txt) - Assuming you have index.php and robots.txt files, this is already handled by the !-f above
    RewriteRule ^(.*)$ index.php?/$1 [L] # OR
    # RewriteRule .? index.php?{REQUEST_URI} [L] - untested; this may capture the / between the domain name and URI so use R=301 to test
    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
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •