Support » Localhost Installs » Permalink Change leads to 404 Error

  • Resolved ov10fac

    (@ov10fac)



    I have installed WP on a local server. Everything seems to be working, but when I changed the permalink from plain to post name I get a 404 error. Here is my .htaccess file:

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

    My wordpress is located in the following directory:
    /var/www/html/wordpress. Running CentOS 7

    Any help appreciated.

Viewing 11 replies - 1 through 11 (of 11 total)
  • RossMitchell

    (@rossmitchell)

    Does your webserver configuration have “mod_rewrite” enabled ? Without it the .htaccess script does not work.
    Easiest way to test is to run the phpinfo function, create a .php file with an obscure name such as phpinfoX23.php with these contents:

    <?php
     phpinfo();
    ?>

    The obscure name is required as the info is conceivably of interest to bad people.

    ov10fac

    (@ov10fac)

    Ok, it shows its loaded. But I don’t see any indications that it is “enabled” unless just being loaded implies enabled.

    I also noticed that when I re-selected the defalt, the conf file was blank.

    Thanks.

    • This reply was modified 11 months ago by  ov10fac.

    Yes loaded implies enabled.

    I also noticed that when I re-selected the defalt, the conf file was blank.

    I don’t understand where you did this selection. More details please.

    The fact that mod_rewrite is loaded doesn’t mean it’s enabled in your web directory. I’d bet that your httpd.conf file has “AllowOverride None” in the system root directory without a corresponding “AllowOverride All” in your web directory. Your .htaccess files will be ignored if you have such a configuration.

    This can be solved in two ways. The first is to change the directive in the system root directory to “AllowOverride All”. It is the easiest solution, but it is a minor security risk as well as potentially slowing down your localhost installation. A better solution is to place an “AllowOverride All” directive in the web directory definition.

    • This reply was modified 10 months, 4 weeks ago by  Dion Designs.

    Ross. When I changed the permalink back to default and reviewed the .htaccess file it only contained the commented lines. The other lines were all deleted.

    DionDesigns – I am familiar with the httd.conf file but not with the a file in the web directory. Can you explain what you mean by that or point me to a reference source to help out?

    Thanks.

    What I mean is that, if your httpd.comf file has a block similar to this:

    <Directory "/">
    	AllowOverride None
    	Require all denied
    </Directory>
    

    You should add another block that looks like this:

    <Directory "/path/to/web/directory">
    	AllowOverride All
    	Require all granted
    </Directory>
    
    • This reply was modified 10 months, 3 weeks ago by  Dion Designs.

    Ok, Updated the http.conf file as you suggested. Also added missing .htaccess file to the root directory (/var/www/html), but I am still getting the 404 error.
    Here is the .htaccess file contents:

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

    Many thanks for your help.

    Did you restart Apache after making the change to httpd.conf? That’s required to activate the changes.

    Also, if you already had a `<Directory “/var/www/html”>’ block defined, add the AllowOverride directive to that block instead of creating a second one.

    Yes, I did restart Apache. Here is what I have in my httpd.conf file. These lines are at the very end of the file.

    <Directory />
    AllowOverride none
    Require all denied
    </Directory>

    <Directory /var/www/html>
    AllowOverride All
    Require all granted
    </Directory>

    Still not working. However, I was able to solve the max file upload size. Now if I can get this fixed, and find a way to get mail working, I should be set.

    the changes to the httpd.conf file seem to have solved the problem.
    Thanks everyone.

    As I said the http.conf file changes recommended fixed the issue. But there were several places that I changed and things seemed to work after that.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Permalink Change leads to 404 Error’ is closed to new replies.