麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 系統(tǒng) > Ubuntu > 正文

Ubuntu14.14開啟ApacheRewrite功能的方法詳解

2024-06-28 14:32:55
字體:
供稿:網(wǎng)友

Ubuntu上開啟Apache Rewrite功能的方法
發(fā)布時間:2012-09-11編輯:腳本學(xué)堂
本文介紹ubuntn系統(tǒng)中開啟apache的urlrewrite功能的方法。


在Windows上開啟Apache的urlRewrite非常簡單,因為apache的用戶配置都是放在http.conf文件中,要開啟Rewrite功能,只需要把該文件中LoadModule rewrite_module modules/mod_rewrite.so前面的注視去掉,然后重啟APACHE即可。

但在Ubuntu上則有所不同,默認(rèn)Apache包配置是按照目錄和文件存放的,/etc/apache2目錄包含conf.d、mods-available、mods-enabled、sites-available、sites-enabled文件夾,apache2.conf、envvars、httpd.conf(用戶配置文件)、magic、ports.conf(APACHE端口配置)配置文件。

一、Ubuntu默認(rèn)未開啟Rewrite支持

其中,mods-available是指可用的模塊,mods-enabled是指當(dāng)前已經(jīng)默認(rèn)加載的模塊。httpd.conf默認(rèn)是個空文件,因為大部分加載工作都被分散到不同的配置文件里,總體加載配置文件是apache2.conf,其部分內(nèi)容如下:

 

# Include module configuration:Include /etc/apache2/mods-enabled/*.loadInclude /etc/apache2/mods-enabled/*.conf# Include all the user configurations:Include /etc/apache2/httpd.conf# Include ports listingInclude /etc/apache2/ports.conf......# Include generic snippets of statementsInclude /etc/apache2/conf.d/# Include the virtual host configurations:Include /etc/apache2/sites-enabled/

  


從這些語句可以看出,加載工作已經(jīng)分散到不同的配置文件,這樣看起來似乎更為合理,管理起來也非常方便。下面看一下如何開啟Rewrite模塊,當(dāng)用戶需使用301重定向、偽靜態(tài)等Rewrite功能時,一般都習(xí)慣于使用.htaccess文件配置,比如下面的301重定向:

 

Options +FollowSymLinksRewriteEngine onRewriteCond %{HTTP_HOST} ^abc.com [NC]RewriteRule ^(.*)$ http://www.shouce.ren/$1 [L,R=301]RewriteCond %{HTTP_HOST} ^www.abc.com[NC]RewriteRule ^(.*)$ http://www.shouce.ren/$1 [L,R=301]

  



配置完成后,使用/etc/init.d/apache2 reload命令加載生效,這時,如果未開啟Rewrite功能,則會出現(xiàn)500錯誤(瀏覽器顯示),查看LOG錯誤如下:
[Sun Jan 30 02:41:29 2011] [alert] [client 12.34.56.78] /srv/www/shouce.ren/public_html/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
說明需要手動開啟Rewrite模塊加載,加載開啟過程如下。

二、手動開啟加載Rewrite

1、使用終端工具連接服務(wù)器,輸入管理員帳號和密碼

2、執(zhí)行加載Rewrite模塊:
a2enmod rewrite
執(zhí)行后,會提示OK和重啟Apache命令(/etc/init.d/apache2 restart)。

3、參照上文的目錄配置,做個啟動鏈接(下次啟動自動加載):

 

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

  

執(zhí)行后會在mods-available目錄下創(chuàng)建一個快捷方式,連接到mods-enabled下rewrite模塊。

4、重啟apache:


/etc/init.d/apache2 restart
三、單一缺省網(wǎng)站配置及重定向參考

如果只有一個網(wǎng)站,且默認(rèn)使用apache分配的默認(rèn)www文件夾(沒有創(chuàng)建單獨的配置文件,比如/sites-availbe/shouce.ren),可能還需要修改/etc/apache2/sites-available/default這個文件,把其中的AllowOverride None修改為AllowOverride All,因為default配置里還默認(rèn)關(guān)閉.htaccess重載,打開后.htaccess才會生效。

<VirtualHost 12.34.56.78:80>ServerAdmin webmaster@localhostDocumentRoot /var/www<Directory />Options FollowSymLinksAllowOverride None</Directory><Directory /var/www/>Options Indexes FollowSymLinks MultiViewsAllowOverride NoneOrder allow,denyallow from all</Directory>ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/<Directory "/usr/lib/cgi-bin">AllowOverride NoneOptions +ExecCGI -MultiViews +SymLinksIfOwnerMatchOrder allow,denyAllow from all</Directory>ErrorLog /var/log/apache2/error.log# Possible values include: debug, info, notice, warn, error, crit,# alert, emerg.LogLevel warnCustomLog /var/log/apache2/access.log combinedAlias /doc/ "/usr/share/doc/"<Directory "/usr/share/doc/">Options Indexes MultiViews FollowSymLinksAllowOverride NoneOrder deny,allowDeny from allAllow from 127.0.0.0/255.0.0.0 ::1/128</Directory></VirtualHost>

  

配置完成后,重啟 Apache,命令:/etc/init.d/apache2 restart

 


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 黄色7777| 亚洲午夜久久久久 | 一级尻逼视频 | 特级无码毛片免费视频尤物 | 亚洲欧美成aⅴ人在线观看 av免费在线播放 | 92看片淫黄大片欧美看国产片 | 久久精品视频日本 | lutube成人福利在线观看污 | av在线播放电影 | 黄色a级片免费观看 | 午夜精品老牛av一区二区三区 | 99麻豆久久久国产精品免费 | 久久久久久久久久久久久久久伊免 | 亚洲欧美国产高清va在线播放 | 13一14毛片免费看 | 色屁屁xxxxⅹ免费视频 | 狠狠操操 | 亚洲第一男人天堂 | 日韩激情在线视频 | 777zyz色资源站在线观看 | 渔夫荒淫艳史 | chinesegv男男猛男无套 | 午夜小网站 | 国产喷白浆10p | www.精品视频| 日韩在线欧美在线 | 老司机免费福利午夜入口ae58 | 国产视频第一区 | 中国美女一级黄色大片 | 成人午夜免费看 | 色无极影院亚洲 | 久久老司机精品视频 | 蜜桃网站在线观看 | 国产精品免费久久久久久 | 成人三级电影在线 | 欧美精品在线视频观看 | 国产一级毛片视频在线! | 国产精品一区99 | 久久成人黄色 | 性 毛片| 国产无遮挡一级毛片 |