Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

only default permalinks working wordpress others become 404 error

My problem is in my wordpress site only default permalinks is working.. When I change permalinks all pages become not found.. only home page is showing.

When I change permalinks to postname .htaccess content change to

# 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

And for default it is

# BEGIN WordPress

# END WordPress

Also tried to get the status of mod_rewrite using this

in_array( 'mod_rewrite', apache_get_modules())

It returns 1 and mod_rewrite is enabled on my server and also checked using phpinfo(). mod_rewrite module is loaded.. I have gone through all the documents available in internet.. Please help me to solve this problem.. My hosting server is godaddy..

like image 763
Girish Sasidharan Avatar asked Mar 19 '14 09:03

Girish Sasidharan


People also ask

Why does permalink not work in WordPress?

4 Reasons Why a Permalink Might be BrokenWhile restoring your backup files or during migrating WordPress to a different server or domain can result in a broken permalink. Once you have updated a plugin, there might be a compatibility issue resulting in a 404 error.

Why is my permalink not working?

The simplest way to deal with this problem is by resetting the permalinks structure: Login to your WordPress Dashboard. Go to Settings > Permalinks. Select an alternative permalinks structure -> Save Changes.

How do I change the default 404 page in WordPress?

In the left-hand menu of the WordPress Admin Dashboard, go to Appearance -> 404 Error Page. Select the page you have just customized as your 404 page and set it as 404-error page that'll be displayedappear by default, when users land on a broken link: Click Save Changes and that's it.


2 Answers

In case you are on Ubuntu, edit the file /etc/apache2/apache2.conf (here we have an example of /var/www):

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

and change it to:

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

also check Apache configuration file for your website /etc/apache2/sites-available/your_site.conf:

<Directory /var/www/your_site_path/>
    AllowOverride None
</Directory>

and change it to:

<Directory /var/www/your_site_path/>
    AllowOverride All
</Directory>

You need to do sudo a2enmod rewrite to enable module rewrite

then,

sudo service apache2 restart

I hope this helps you!

like image 182
Kazbek Kadalashvili Avatar answered Sep 16 '22 16:09

Kazbek Kadalashvili


It could be a broken rewrite_rules field in your database.

I installed "Yoast SEO" into a live site and that broke it completely. I disabled the plugin but it didn't go back to working. Only default permalinks would work.

Like everyone else I tried the usual things - checking .htaccess, making sure that mod_rewrite was working on the server, saving the permalinks settings again, but nothing was working. The homepage would load, and wp-admin pages would load, but everything else was just loading the "Latest Posts" default page.

In the end it turned out to be something wrong with the rewrite_rules field of wp_options in the database.

I had three versions of the site (local, staging and production), and all were from one SVN base, so I knew it was not a file issue. But only the local development version was working.

I replaced the contents of the rewrite_rules field of the broken live site with the working one from my local development site, and it worked.

What's really weird is that deleting the rewrite_rules field and having WordPress rebuild it did not fix the problem. Only replacing with the contents of a previously working version of the site did the trick.

I'm still puzzled by this, and will edit this reply if I find out anything further about the problem.

like image 33
codewithfeeling Avatar answered Sep 19 '22 16:09

codewithfeeling