標籤:apache
1.開啟rewrite模組
vim httpd.conf#[plain] view plain copyLoadModule rewrite_module modules/mod_rewrite.so
2.開啟AllowOverride
[plain] view plain copy# # 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 修改 AllowOverride None 為 AllowOverride All
關於AllowOverride 說明:
AllowOverride參數就是指明Apache伺服器是否去找.htaccess檔案作為設定檔,如果設定為none,那麼伺服器將忽略.htacess檔案,如果設定為All,那麼所有在.htaccess檔案裡有的指令都將被重寫。對於AllowOverride,還可以對它指定如下一些能被重寫的指令類型. 通常利用Apache的rewrite模組對 URL 進行重寫的時候, rewrite規則會寫在 .htaccess 檔案裡。但要使 apache 能夠正常的讀取.htaccess 檔案的內容,就必須對.htaccess 所在目錄進行配置。從安全性考慮,根目錄的AllowOverride屬性一般都配置成不允許任何Override ,即 代碼如下: <Directory /> AllowOverride None </Directory>在 AllowOverride 設定為 None 時, .htaccess 檔案將被完全忽略。當此指令設定為 All 時,所有具有 ".htaccess" 範圍的指令都允許出現在 .htaccess 檔案中。 而對於 URL rewrite 來說,至少需要把目錄設定為 代碼如下: < Directory /myblogroot/> AllowOverride FileInfo < /Directory>
3.允許apache支援.htaccess
[plain] view plain copyOptions FollowSymLinks AllowOverride None 修改為[plain] view plain copyOptions FollowSymLinks AllowOverride All
4.重啟進程
systemctl restart httpd.service
本文出自 “深呼吸再出擊” 部落格,請務必保留此出處http://ckl893.blog.51cto.com/8827818/1928134
centos 開啟apache偽靜態