Wordpress Links Breaking Website
-
@scottalanmiller said:
Example file:
-bash-4.1$ cat .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>Those are automatically generated by Wordpress if the correct settings in Apache to AllowOverride are set correctly. As long as the Wordpress user has write permissions and Apache is right, that's auto-generated. It was because I just checked and that exact set of code is there.
-
So your .htaccess file looks like that?
-
@scottalanmiller said:
So your .htaccess file looks like that?
Correct. It's between a couple of comments that say WORDPRESS. It was automatically generated. Apache missing that setting was the issue. Wordpress is SUPPOSED to automatically generate it.
-
@ajstringham said:
So I'm going to put this here so that it might help someone else. I tried changing the Permalinks format on my site from the default "?p=123" to anything else. Anytime I did, I got an error. Doing some research, I found I needed a .htaccess file, which wasn't being generated automatically. So I created it in vi and gave it permissions to be written to. I've tried this before though, and yet any non-default permalinks style breaks my site. I finally found the solution. In this link:
http://wordpress.org/support/topic/solved-permalinks-working-in-apache2-ubuntu-1010#post-2421733Now the link has the right setting but that file didn't have what I needed. Using some powers of deduction, I went up a level and modified the apache2.conf file in /etc/apache2. If you go about 80% of the way down, you'll see (not gonna type everything):
<Directory /var/www/>
AllowOverride None
</Directory>Now, there are multiple Directory containers so get the right one. Change None to All. After that, run service apache2 restart. I'm running Ubuntu Server 14.04 as a LAMP server, so, that's what I have to do. Basically, restart apache. After I did that, with my .htacess file in place, everything works! Hope this helps someone else!
Thanks,
A.J.I've honestly left my permalinks alone for the .htaccess reason; I'll have to check it out next time someone requests specific URL's! Thanks @ajstringham
-
Maybe it is Ubuntu doing something specific. It "just works" on CentOS.
-
@scottalanmiller said:
Maybe it is Ubuntu doing something specific. It "just works" on CentOS.
Oh shut up about CentOS. I saw people on CentOS having the exact same issue.
-
I've done a lot of CentOS setups of that and don't recall that coming up.
-
Just ran into an issue where this wasn't working again. Solved by running...
sudo a2enmod rewrite
Everything else was the same. Leaving this here as reference.
-
@thanksaj said:
sudo a2enmod rewrite
So it was your Apache config
-
@thecreativeone91 said:
@thanksaj said:
sudo a2enmod rewrite
So it was your Apache config
Always has been in any issue like this that I have come across.
-
@thecreativeone91 said:
@thanksaj said:
sudo a2enmod rewrite
So it was your Apache config
I figured it was. I just couldn't find the solution. I'm documenting it here as much for myself for the possibility I need it again in the future as others.