• Can anyone please explain in simple terms exactly what this wp mod_rewrite code is doing..

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

Viewing 5 replies - 1 through 5 (of 5 total)
  • I don’t know about simple terms, but here’s the doc page from apache: https://httpd.apache.org/docs/1.3/mod/mod_rewrite.html and here’s a little more info also from apache: https://httpd.apache.org/docs/1.3/misc/rewriteguide.html

    My interpretation of that code is:
    RewriteEngine On
    # Wake up the rewriting elves!
    RewriteBase /
    # Start with the server root.
    RewriteCond %{REQUEST_FILENAME} !-f
    # If the request is for a real directory (one that exists
    # on the server), index.php isn’t served.
    RewriteCond %{REQUEST_FILENAME} !-d
    # If the request is for a file that exists already on
    # the server, index.php isn’t served.
    RewriteRule . /index.php [L]
    # This is the rule that corresponds to the above two
    # conditions. I think it will put /index.php on the
    # end of any request that does not match the conditions.
    # I think.

    Actually, the answers for the %{REQUEST_FILENAME} bits I copied from this thread over here:
    https://forum.mamboserver.com/archive/index.php/t-42366.html

    This is pretty confusing stuff. Here’s a little more info in regards to permalinks: https://codex.www.ads-software.com/Using_Permalinks but I’m still trying to research some weird behavior with this exact set of rules, but using the litespeed server software.

    Like a dinghy afloat on the sea of life.

    The problem I’m having is that while this set of rules works like a charm under Apache, it behaves a little too free and easy under Litespeed. Meaning:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    …will rewrite absolutely any string at all as a directory and then slap index.php on the end of it. The actual 404 never gets served.

    Very puzzling.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    WordPress handles 404 errors internally. That’s what the 404.php is for in the theme.

    And those rules essentially say to redirect any hit for a file that does not actually exist to WordPress’s main entry point (the root index.php file). Because WordPress will parse the URL and figure out where to go from there.

    Thanks Otto. Do you have any idea why, when using Litespeed, WordPress parses the URL and fails to figure out where to go? (Whereas the same setup on Apache just works.) Do you think the rewrite rules are actually *not* the problem? And if not, then what?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Err.. No. With Litespeed it should just work, no issues. If WordPress loads on a pretty permalink, then it’s working.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘mod_rewrite for wordpress.’ is closed to new replies.