One of my droplets got compromised and for some reason I cannot get permalinks working on the new droplet. I copied over all code and Apache settings, turned the permalinks off and back on in the WP admin, but the permalinks will not work.
I’ve tried everything I can think of. What do I need to do to get them working again? Thanks.
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.
On a new apache setup there are two common reasons that Wordpress permalinks would not be working.
1.) Make sure you have enabled mod_rewrite in apache. This can be done by running:
a2enmod rewrite
and then restarting apache
service apache2 restart
2.) Check your virtualhost configuration in /etc/apache2/sites-enabled/ and make sure that it is configured with AllowOverride All
instead of the default AllowOverride None
for your web root directory. This tells apache it is ok for settings in .htaccess files to override settings.
I had the same issue and after some research I found this solution:
http://haydenjames.io/disable-htaccess-wordpress-performance/
Basically, you need to add the information that is found in the WordPress .htaccess file to the main apache configuration file. .htaccess files are only meant to be used in situations where you don’t have access to the main configuration file, like when you are using shared hosting.
If you’re using Digital Ocean you have access to the main configuration file, so you shouldn’t be using .htaccess files and you should have “AllowOveride None” set to increase apache performance.
I just went back and looked at your config file for your site and saw you have virtualhost defined twice…not sure why.
Perhaps simplify that a bit like something like:
<VirtualHost *:80>
ServerName www.XXX.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/XXX.com
ServerAlias XXX.com
<Directory /var/www/html/XXX.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
CustomLog ${APACHELOGDIR}/XXX.log common
ErrorLog ${APACHELOGDIR}/XXX-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
and finally, Maybe do (just to be sure) :
sudo chown -R www-data:www-data /var/www
and
sudo chmod -R 774 /var/www
Hello Please see my site حرف اخر I use WordPress. Currently, I set the links as %category% / %post%
There is no problem posting content as site.com/category/subcategory/post But when site.com/category/post is written, a redirection operation must be done, but the subject is also visible on this page. And this problem causes the problem of Google’s duplicate content What is your suggestion? Please help me
I used a similar setup with ThomasTom’s resource to use the rewrite in the conf file (and disable .htaccess completely):
/etc/apache2/sites-available/mysecondsite.com.conf:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/mysecondsite.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride none
# 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>
</Directory>
</VirtualHost>
Don’t forget to reboot apache2
sudo systemctl restart apache2
I was able to get it working. I guess there was a secondary issue with one of the plugins causing the pages not to load.
This is way frustrating. I hope someone can help me out with this. When I click on a permalink the pages fail to load and I get this error from Chrome’s console: {“@context”:“http://schema.org”,“@type”:“WebSite”,“url”:“http://lineangel.com/",“name”:"LineAngel”}
I tried this https://randomwordpresstips.wordpress.com/2013/05/10/enabling-permalinks-on-wordpress-install-ubuntu-12-10/ with no luck.
a2enmod rewrite is enabled .htaccess file is set to “chmod 666″
My .htaccess file is:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
My apache2.conf file is:
ServerRoot “/etc/apache2” Mutex file:${APACHE_LOCK_DIR} default PidFile ${APACHE_PID_FILE} Timeout 300 KeepAlive On MaxKeepAliveRequests 100 KeepAliveTimeout 5 User ${APACHE_RUN_USER} Group ${APACHE_RUN_GROUP} HostnameLookups Off ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel crit IncludeOptional mods-enabled/.load IncludeOptional mods-enabled/.conf Include ports.conf
<Directory /> Options FollowSymLinks AllowOverride all <Limit PUT DELETE CONNECT OPTIONS PATCH PROPFIND PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> deny from all </Limit> </Directory>
<Directory /var/www> Options FollowSymLinks AllowOverride FileInfo </Directory>
<Directory /usr/share> AllowOverride all Require all granted </Directory>
AccessFileName .htaccess
<FilesMatch “^.ht”> Require all denied </FilesMatch>
AccessFileName .htaccess
<FilesMatch “^.ht”> Require all denied </FilesMatch>
LogFormat “%v:%p %h %l %u %t “%r” %>s %O “%{Referer}i” “%{User-Agent}i”” vhost_combined LogFormat “%h %l %u %t “%r” %>s %O “%{Referer}i” “%{User-Agent}i”” combined LogFormat “%h %l %u %t “%r” %>s %O” common LogFormat “%{Referer}i -> %U” referer LogFormat “%{User-agent}i” agent
IncludeOptional conf-enabled/.conf IncludeOptional sites-enabled/.conf
<DirectoryMatch ^.*/wp-content/uploads/> AllowOverride all php_flag engine off php_admin_value engine Off </DirectoryMatch>
<DirectoryMatch ^.*/wp-content/blogs.dir/> AllowOverride all php_flag engine off php_admin_value engine Off </DirectoryMatch>
#<DirectoryMatch ^.*/wp-admin/>
#</DirectoryMatch>
<VirtualHost *:80> ServerAdmin webmaster@lineangel DocumentRoot /var/www Servername localhost ServerAlias lineangel www.lineangel
<Directory /var/www/html/lineangel.com> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny allow from all </Directory> </VirtualHost>
My 000-default.conf is:
<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/html
# 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/html/lineangel.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Any help would be greatly appreciated!
Maybe do (just to be sure) :
sudo chown -R www-data:www-data /var/www
and
sudo chmod -R 774 /var/www
what are you trying to save your permalinks as?
when you save permalinks, do you get any errors at the bottom of the page?
try saving permalinks twice…click save…click save
This comment has been deleted
Digital Ocean should really consider a default WordPress droplet which has the URL rewrites enabled by default. This is just standard WordPress stuff and thousands of us have to fumble around with command lines just to get pretty links to work.
C’mon D.O., you can do it!