WordPress.org

Ready to get started?Download WordPress

Forums

What should .htaccess look like? (7 posts)

  1. gpvillamil
    Member
    Posted 5 years ago #

    What needs to be in the .htaccess file in the root directory?

    I recently removed Gallery2 and the wp-gallery2 plugin, and think they have left a lot of clutter:

    # BEGIN Url Rewrite section
    # (Automatically generated. Do not edit this section)
    <IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
    RewriteCond %{REQUEST_FILENAME} !/wp-gallery2\.php$
    RewriteRule . - [L]

    RewriteCond %{THE_REQUEST} \ /d/([0-9]+)-([0-9]+)/([^\/\?]+)(\?.|\ .)
    RewriteCond %{REQUEST_FILENAME} !/wp-gallery2\.php$
    RewriteRule . /gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3 [QSA,L]

    RewriteCond %{THE_REQUEST} \ /v/([^?]+)(\?.|\ .)
    RewriteCond %{REQUEST_FILENAME} !/wp-gallery2\.php$
    RewriteRule . /wp-gallery2.php?g2_view=core.ShowItem&g2_path=%1 [QSA,L]

    </IfModule>

    # END Url Rewrite section

    How much of that can I get rid of?

  2. Ripose
    Member
    Posted 5 years ago #

    Here is a VERY BASIC .htaccess

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

    Let us know if this helped!

  3. gpvillamil
    Member
    Posted 5 years ago #

    Maybe... what does that do?

  4. Ripose
    Member
    Posted 5 years ago #

    All it does is check to see if you have mod_rewrite installed, if so it is applied to the way Apache operates, if not, it does nothing.

    It gets kind of detailed, so it would be better if you searched for mod_rewrite/Apache to get a proper description.

    mod_rewrite

    mod_rewrite is an extension module of the Apache web server software which allows for "rewriting" of URLs on-the-fly. Rewrite rules use regular expressions to parse the requested URL from the client, and translate it into a different URL before interpretation.

    WordPress uses mod_rewrite for its permalink structure, which is optional functionality.

    Related articles: Using Permalinks

    It is a default .htaccess found in many WP sites.

  5. gpvillamil
    Member
    Posted 5 years ago #

    So is that something I should see if I enable permalinks in WordPress?

    Will it be generated automatically, or do I have to create it myself?

  6. iridiax
    Member
    Posted 5 years ago #

  7. gpvillamil
    Member
    Posted 5 years ago #

    Hmmm. That does not seem to be working.

    When I choose "pretty" Permalinks in wp-admin, it says it's made the changes successfully. However, going to my site and clicking on post titles returns an error: "No input file specified. "

    I notice that the .htaccess file is unchanged. Write permissions to the file are enabled, and I do not get an error message in WP when saving changes to the permalink structure.

    In any case, I've since manually created a .htaccess file that prevents access to wp-config, that seems to work fine.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags