Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
378 views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...