Why aren't my Wordpress permalinks working?

December 5, 2016 8k views
CentOS WordPress

I have a Wordpress site in a sub directory:


When I visit http://myip/mysite/ it works with “Plain” permalinks (i.e. http://myip/mysite?page_id=6) and I can navigate the site.

However, when I use “Post name” permalinks (i.e. http://myip/mysite/mypage/), I get a 404. It works fine locally. This is what my .htaccess file looks like:

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

Under Settings > General in Wordpress, I have both the Wordpress Address and Site Address set to:


What am I missing?

2 Answers

Hi @eightysix

Have you modified Apache virtual file for your domain to Allow URL rewrites? If not, here’s how you go about it:

Open the the Apache virtual file for your domain to make changes:

sudo nano /etc/apache2/sites-available/mysite.conf

Make these additions on the file

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/mysite
    ServerName server_domain_name_or_IP
    <Directory /var/www/mysite>
        AllowOverride All
    . . .

Save and exit then enable mode rewrite which allows you to modify URLs:

sudo a2enmod rewrite

Reload Apache

sudo service apache2 reload
  • Thanks. That cured my problem. I had an issue where it worked when in local dev environment but not on the live site.

    This was an issue because I have a forum which needs the permalinks to be “not” default for some reason.

  • Thank you so much. This did the trick. Now I have a functional multi-site setup with subdomains and everything. Not bad for an amateur. Thank you very much!

  • This is golden! I have experienced this so many times. this worked like a charm

I don’t actually have a virtual host setup, but I believe I have allowed URL rewrites globally in my phpmyadmin file. I followed the instructions here:


sudo nano /etc/apache2/conf-available/phpmyadmin.conf

I added AllowOverride All to <Directory /usr/share/phpmyadmin>.

Then I restarted apache, but that didn’t work…

Do I require a virtual host?

by Justin Ellingwood
While many users require access to a database management system like MySQL, not all users feel comfortable interacting with the MySQL prompt on a daily basis. In this guide, we'll discuss how to install and secure phpMyAdmin, a web management interface for MySQL, on an Ubuntu 14.04 server.
  • I’m looking at this tutorial:


    In the How to permit changes in the .htaccess file section, I see that I should be editing the default config file:

    sudo nano /etc/apache2/sites-available/default

    I’m apparently supposed to change AllowOverride None to AllowOverride All in <Directory /var/www/>, however, that file does not exist.

    I only see 000-default.conf and inside of that I do not see <Directory /var/www/>. Instead I see <VirtualHost *:80>. I’m not sure what I am missing.

    by Etel Sverdlov
    This tutorial goes over Mod_Rewrite, an apache module that allows you to manipulate URLS to provide shorter or more relevant ones. This tutorial will go over Activating Mod_Rewrite, Creating and Using the required .htaccess page, and setting up the URL rewrites.
    • Ok, I found a thread discussing this and I think I have it working now.


      I added my directory to the Virtual Host and allowed overrides for that specific directory. This is what 000-default.conf looks like now:

      <VirtualHost *:80>
              # The ServerName directive sets the request scheme, hostname and port that
              # the server uses to identify itself. This is used when creating
              # redirection URLs. In the context of virtual hosts, the ServerName
              # specifies what hostname must appear in the request's Host: header to
              # match this virtual host. For the default virtual host (this file) this
              # value is not decisive as it is used as a last resort host regardless.
              # However, you must set it for any further virtual host explicitly.
              #ServerName www.example.com
              ServerAdmin webmaster@localhost
              DocumentRoot /var/www
              # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
              # error, crit, alert, emerg.
              # It is also possible to configure the loglevel for particular
              # modules, e.g.
              #LogLevel info ssl:warn
              ErrorLog ${APACHE_LOG_DIR}/error.log
              CustomLog ${APACHE_LOG_DIR}/access.log combined
              # For most configuration files from conf-available/, which are
              # enabled or disabled at a global level, it is possible to
              # include a line for only one particular virtual host. For example the
              # following line enables the CGI configuration for this host only
              # after it has been globally disabled with "a2disconf".
              #Include conf-available/serve-cgi-bin.conf
              <Directory /var/www/mysite>
                  Options Indexes FollowSymLinks MultiViews
                  AllowOverride All
                  Order allow,deny
                  allow from all
                      Require all granted

      The important part is the addition of:

      <Directory /var/www/mysite>
          Options Indexes FollowSymLinks MultiViews
          AllowOverride All
          Order allow,deny
          allow from all
              Require all granted

      This seems to be working!

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!