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) 查看頁面即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章