Ubuntu上WordPress更新固定链接方法总结

Ubuntu下WordPress更新固定链接方法总结

原因:

SEO,优化自己文章的搜索,实践证明, /%postname%.html 的SEO是最好的,因为标题和链接同时被搜索。

千万不要改成 /%postname%/, 这样你的所有文章将不会被搜索引擎收录。

系统:


Ubuntu,linux系统一直使用RedHat, Ubuntu不太熟悉,但是大同小异,不懂的查。

方法:


1) 进入wordpress 后台,更改固定链接为 /%postname%.html
2) AllowOverride ALL

现在apache2不依靠httpd.conf来配置。 Ubuntu下默认的配置文件是/etc/apache2/sites-available/default 可以修改上面文件来修改apache2配置,
<Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
        Order allow,deny
        allow from all
</Directory> 
3) 开启module: rewrite

使用指令:a2enmod rewrite

4) 修改.htaccess为:

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
 

5) 重启 apache2

使用指令:sudo /etc/init.d/apache2 restart
或:sudo service apache2 restart

6) 查看页面即可