Ubuntu - Discuz X3.1 僞靜態

1. .htaccess放到網站根目錄php

RewriteEngine On

RewriteBase /

RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topic=$1&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ plugin.php?id=$1:$2&%1

 

2. 開啓mod_rewrite模塊html

能夠經過phpinfo()函數來查看mod_rewrite是否開啓。apache

開啓方法:vim

sudo a2enmod rewrite           //即啓用了 Mod_rewrite 模塊。ide

另外,也能夠經過將 /etc/apache2/mods-available/rewrite.load 鏈接到 /etc/apache2/mods-enabled/rewrite.load 來打開 Mod_rewrite 模塊。函數

用指令操做就是:網站

sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.loadui

 

3. 將AllowOverride設爲All (注意是2個地方)spa

sudo vim /etc/apache2/sites-enabled/000-defaultrest

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

 

最後,重啓 Apache:

sudo /etc/init.d/apache2 restart.

 

 

另外補充CentOS的

/etc/httpd/conf/httpd.conf

/etc/httpd/conf.d/php.conf
修改這兩個文件的 AllowOverride 
相關文章
相關標籤/搜索