Girish Sasidharan
Girish Sasidharan

Reputation: 588

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

Upvotes: 7

Views: 14332

Answers (7)

Bright Onapito
Bright Onapito

Reputation: 399

I faced the same challenge after setting up WordPress on Ubuntu 22 and configuring an SSL certificate for the site. This is how I was able to resolve it.

Open the apache config file for editing (using nano in this case)

 sudo nano /etc/apache2/apache2.conf

Change the following line:

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

to:

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

Open the default SSL config file for editing

sudo nano /etc/apache2/sites-available/default-ssl.conf

Add the following code:

<Directory "/var/www/html">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
</Directory>

Restart Apache

sudo service apache2 restart

You should now be able to change the site permalink structure without seeing the 404 page not found error.

Upvotes: 1

er2r23r
er2r23r

Reputation: 11

I had this issue in Wordpress installed on CentOS7 and the solution was to edit httpd.conf file with this command:

sudo vi /etc/httpd/conf/httpd.conf

And replace

<Directory "/var/www/wordpress">
Options Indexes FollowSymLinks
AllowOverride none
Require all granted
</Directory>

with

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

then restart Apache:

sudo systemctl restart httpd.service

Upvotes: 1

Kazbek Kadalashvili
Kazbek Kadalashvili

Reputation: 340

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!

Upvotes: 17

Gerald
Gerald

Reputation: 31

suffered from the same issue. Having site on SSL had to change NOT the 000-default.conf but the respective SSL conf file. Adding

after DocumentRoot /var/www/html

the following

<Directory "/var/www/html">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
</Directory>

and then restarting apache2 saved my site.... nothing else worked. The issue was Wordpress SSL and SEO plugins messing up config files.

Upvotes: 3

Brien Crean
Brien Crean

Reputation: 2648

I had the exact same issue and fixed it by running

sudo a2enmod rewrite

Then restarted apache. Apparently the issue is caused by mod_rewrite potentially not working properly on ubuntu.

I found the solution here

Upvotes: 4

Keshan
Keshan

Reputation: 14677

Not sure this is too late. i faced the same issue and solved by changing

AllowOverride None

to

AllowOverride All

in /etc/apache2/sites-enabled/000-deafult.conf file. hope this would help.

Upvotes: 0

codewithfeeling
codewithfeeling

Reputation: 6576

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.

Upvotes: 8

Related Questions