1,798 瀏覽數

Drupal – Clean URLs

Clean URLs 為非必要的東西,但是有些模組就需要他.像是 imagecache.系統預設是不支援我們必須修改 /etc/httpd/conf/httpd.conf

[root@benjr ~]# vi /etc/httpd/conf/httpd.conf
DocumentRoot /var/www/html
#DocumentRoot 是依據你網站位置來存放,我的 drupal 是放在 /var/www/html,其他的就照打就是了.
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
#
# Note that from this point forward you must specifically allow
# particular features to be enabled – so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
#
# This should be changed to whatever you set DocumentRoot to.
#
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* — "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs-2.0/mod/core.html#options
# for more information.
#
<Directory /var/www/html>
   RewriteEngine on
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>
# Clean URL 主要就是這一段敘述
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
[root@benjr ~]# service httpd restart

設定完成之後完成下面的步驟就大功告成了.
cleanurl01

cleanurl02

  1. 點選管理/網站設定/簡潔網址
  2. 再說明欄裡面有一個"執行簡潔網址測試",點選它.
  3. 如果你可以看到下面的回應就代表你剛剛的設定是正確的而且就可以啟動"簡潔網址",就這樣大功告能,如果網站出現不能顯示之類的,請再檢查一下關於 httpd.conf 的設定.

2 個網友的想法 “Drupal – Clean URLs

  1. 自動參照通知: Drupal 7 – Benjr.tw 搬家 | Benjr.tw

  2. 原先一直不敢啟動 clear url 的功能,以為啟動這項功能後我的網頁連結必須從 ?q=node/ 自行修改所有的網頁為 node/,但是我想錯了,其實 clear url 的功能可以使用簡潔網址而且並不影響原先的連結方式,所以網站如果已經運行過一段時間了都還是可以直接啟動,連結並不會受到影響.也不需自行修改.

發表迴響