only default permalinks working wordpress others b

2019-05-30 05:13发布

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

5条回答
一夜七次
2楼-- · 2019-05-30 05:45

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

查看更多
老娘就宠你
3楼-- · 2019-05-30 05:47

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.

查看更多
手持菜刀,她持情操
4楼-- · 2019-05-30 05:47

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.

查看更多
等我变得足够好
5楼-- · 2019-05-30 05:49

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.

查看更多
6楼-- · 2019-05-30 05:52

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!

查看更多
登录 后发表回答