By jamesburns77
Hi,
I have a Wordpress site running on Ubuntu 16.04 installed using Digital Oceans wonderful 1-click install - I even have multiple domains redirecting to one primary parent domain! Not bad for a rookie! I then got some confidence and upgraded my site to https using LetsEncrypt also thanks to the useful guides available from DO. Rookie confidence increasing!
Yesterday I purchased a premium theme, installed it and moved the permalink structure to ‘post name’ and all hell broke lose as any permalinks on the homepage to my site no longer work (they now get a The requested URL <subURL> was not found on this server.).
I recognize this is something this is something that catches out a number of people so have tried various DO articles on the matter to no avail. Fixes attempted include:
Rookie confidence draining, any expertise thrown my way would be much-appreciated Team DO:) The most re-booted site in the world today is available at www.wealth-hack.com…
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Unless you’ve modified apache2.conf, then we shouldn’t need to venture there, however, posting the contents of both 000-default-ssl.conf and default-ssl.conf would be helpful so we can take a closer look at the full configuration.
As for your .htaccess file, I would keep it as basic as possible and stick to the plain-jane default that WordPress uses until we figure out what’s going on.
The most basic/default would be something such as:
# 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
By default, if you set the WordPress URL’s to use https:// then you shouldn’t need to rewrite them, which is why I recommend using the stock .htaccess over anything else right now.
To help expedite this so we can get this resolved for you, I just deployed a one-click image for WP to pull the configuration directly.
So let’s get started :-).
I’m going to run through the steps again in this reply so we can better troubleshoot the issue as we go along. This allows provides a reference point for you to use in the future, should you need to.
…
To start, I’ve ran:
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install python-letsencrypt-apache
Ubuntu is now updated, all packages that need to be are upgraded, and LetsEncrypt is installed. Now before I run LetsEcrypt, let’s take a look at my domain’s configuration file.
I’ve added ServerName and ServerAlias to match both versions of my domain. Those are the only changes I’ve made and they exist on the 4th and 5th lines of the following VirtualHost block.
The contents of 000-default.conf are:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName mydomain.com
ServerAlias www.mydomain.com
<Directory /var/www/html/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The reason I did this is because LetsEncrypt tries to search for the domain you’re trying to secure, so this makes it a little easier as it will automatically find that this configuration file is associated with my domain, so it’s the right one to use.
Now we’ll run LetsEncrypt to generate an SSL Certificate for my domain.
sudo letsencrypt --apache -d mydomain.com -d www.mydomain.com
After entering my e-mail and accepting the terms of service, I’ll be asked:
Please choose whether HTTPS access is required or optional
Since I want HTTPS to be global, I’ll choose:
Secure Make all requests redirect to secure HTTPS access
Once the above option is chosen, LetsEncrypt reports success, apache2 is automatically restarted and SSL now works without having to do anything further.
…
Now, here’s the contents of my configuration files for reference.
/etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName mydomain.com
ServerAlias www.mydomain.com
<Directory /var/www/html/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =mydomain.com [OR]
RewriteCond %{SERVER_NAME} =www.mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>
/var/www/html/.htaccess
# 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
…
If you compare yours the the above, we should be able to figure out what’s going on :-).
…just to mention this to exclude it from possible issues:
I see that the original poster tried chmod, but did not chown the .htacess. Sometimes a person will login as a user and create website files (like an .htaccess) and forget to change the owner (chown) back to www-data.
sudo chown -R www-data:www-data /var/www/html sudo chmod 740 /var/www/html/.htaccess
probably not a good idea to make your .htaccess 666, since that is the mark of the devil
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.