Question

Why aren't my Wordpress permalinks working?

I have a Wordpress site in a sub directory:

/var/www/mysite/

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]
</IfModule>
# END WordPress

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

http://myip/mysite

What am I missing?

Subscribe
Share

This comment has been deleted


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

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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
    </Directory>
    . . .

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

sudo a2enmod rewrite

Reload Apache

sudo service apache2 reload

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
    </Directory>
    . . .

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

sudo a2enmod rewrite

Reload Apache

sudo service apache2 reload

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:

https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-14-04

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?