域名跳轉(zhuǎn)
網(wǎng)站建設哪家好,找創(chuàng)新互聯(lián)建站!專注于網(wǎng)頁設計、網(wǎng)站建設、微信開發(fā)、微信小程序開發(fā)、集團企業(yè)網(wǎng)站建設等服務項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了興隆免費建站歡迎大家使用![root@localhost ~]# vi /usr/local/apache2/conf/extra/httpd-vhosts.conf
*************************************
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.aaa.com$ [OR]//注意空格
RewriteCond %{HTTP_HOST} ^www.bbb.com$
RewriteRule ^/(.*)$ http://www.123.com/$1 [R=301,L]
</IfModule>
或者: <IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.123.com$//注意空格
RewriteRule ^/(.*)$ http://www.123.com/$1 [R=301,L]
</IfModule>
************************
[root@localhost ~]# curl -x127.0.0.1:80 www.123.com -I
HTTP/1.1 301 Moved Permanently
Date: Tue, 05 May 2015 18:40:12 GMT
Server: Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28
X-Powered-By: PHP/5.3.28
location: forum.php
Cache-Control: max-age=0
Expires: Tue, 05 May 2015 18:40:12 GMT
Content-Type: text/html
[root@localhost ~]# curl -x127.0.0.1:80 www.aaa.com -I
HTTP/1.1 301 Moved Permanently
Date: Tue, 05 May 2015 18:40:21 GMT
Server: Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28
Location: http://www.123.com/
Cache-Control: max-age=0
Expires: Tue, 05 May 2015 18:40:21 GMT
Content-Type: text/html; charset=iso-8859-1
[root@localhost ~]# curl -x127.0.0.1:80 www.bbb.com -I
HTTP/1.1 301 Moved Permanently
Date: Tue, 05 May 2015 18:40:28 GMT
Server: Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28
Location: http://www.123.com/
Cache-Control: max-age=0
Expires: Tue, 05 May 2015 18:40:28 GMT
Content-Type: text/html; charset=iso-8859-1
配置靜態(tài)文件緩存
[root@localhost ~]# vi /usr/local/apache2/conf/extra/httpd-vhosts.conf
<Ifmodule mod_headers.c>
<filesmatch "\.(html|htm|txt)$">
header set cache-control "max-age=3600"
</filesmatch>
<filesmatch "\.(css|js|swf)$">
header set cache-control "max-age=604800"
</filesmatch>
<filesmatch "\.(ico|gif|jpg|jpeg|png|flv|pdf)$">
header set cache-control "max-age=29030400"
</filesmatch>
</ifmodule>
[root@localhost ~]# curl -x127.0.0.1:80 www.123.com/static/js/logging.js -I
HTTP/1.1 200 OK
Date: Tue, 05 May 2015 18:59:19 GMT
Server: Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28
Last-Modified: Fri, 26 Dec 2014 01:49:42 GMT
ETag: "22a88-25b-50b14bd049980"
Accept-Ranges: bytes
Content-Length: 603
cache-control: max-age=604800
Content-Type: application/javascript
配置訪問控制
[root@localhost ~]# vi /usr/local/apache2/conf/extra/httpd-vhosts.conf
<Directory /data/www/>
<filesmatch ".*">
Order deny,allow
Deny from all
Allow from 127.0.0.1
</filesmatch>
</Directory>
[root@localhost ~]# curl -x192.168.1.110:80 www.123.com/1.txt -I
HTTP/1.1 403 Forbidden
Date: Tue, 05 May 2015 19:17:26 GMT
Server: Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28
Content-Type: text/html; charset=iso-8859-1
[root@localhost ~]# curl -x127.0.0.1:80 www.123.com/1.txt -I
HTTP/1.1 200 OK
Date: Tue, 05 May 2015 19:18:49 GMT
Server: Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28
Last-Modified: Sat, 02 May 2015 15:22:31 GMT
ETag: "2325b-a-5151ae5c57002"
Accept-Ranges: bytes
Content-Length: 10
cache-control: max-age=3600
Content-Type: text/plain
這樣配置會導致不能訪問網(wǎng)站,在工作中是不允許的,一般應用于禁止訪問網(wǎng)站的重要目錄。
禁止訪問某個目錄:
[root@localhost ~]# vi /usr/local/apache2/conf/extra/httpd-vhosts.conf
<Directory /data/www/admin/>
<filesmatch ".*">
Order deny,allow
Deny from all
Allow from 127.0.0.1
</filesmatch>
</Directory>
[root@localhost ~]# curl -x127.0.0.1:80 www.123.com/admin/1.txt -I //沒有創(chuàng)建目錄及文件導致錯誤
HTTP/1.1 404 Not Found
Date: Tue, 05 May 2015 19:23:04 GMT
Server: Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28
Content-Type: text/html; charset=iso-8859-1
[root@localhost ~]# mkdir /data/www/admin/
[root@localhost ~]# touch /data/www/admin/1.txt
[root@localhost ~]# curl -x127.0.0.1:80 www.123.com/admin/1.txt -I
HTTP/1.1 200 OK
Date: Tue, 05 May 2015 19:24:08 GMT
Server: Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28
Last-Modified: Tue, 05 May 2015 19:24:06 GMT
ETag: "2325e-0-5155a9f3c2ff5"
Accept-Ranges: bytes
cache-control: max-age=3600
Content-Type: text/plain
X-Pad: avoid browser bug
[root@localhost ~]# curl -x192.168.1.110:80 www.123.com/admin/1.txt -I
HTTP/1.1 403 Forbidden
Date: Tue, 05 May 2015 19:24:23 GMT
Server: Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28
Content-Type: text/html; charset=iso-8859-1
禁止訪問某個文件
[root@localhost ~]# vi /usr/local/apache2/conf/extra/httpd-vhosts.conf
<Directory /data/www/>
<filesmatch "^admin.php(.*)$">
Order deny,allow
Deny from all
Allow from 127.0.0.1
</filesmatch>
</Directory>
[root@localhost ~]# curl -x192.168.1.110:80 www.123.com/admin.phpsfsafa -I
HTTP/1.1 403 Forbidden
Date: Tue, 05 May 2015 20:12:46 GMT
Server: Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28
Content-Type: text/html; charset=iso-8859-1
[root@localhost ~]# curl -x192.168.1.110:80 www.123.com/admin.php -I
HTTP/1.1 403 Forbidden
Date: Tue, 05 May 2015 20:15:35 GMT
Server: Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28
Content-Type: text/html; charset=iso-8859-1
[root@localhost ~]# curl -x127.0.0.1:80 www.123.com/admin.php -I
HTTP/1.1 200 OK
Date: Tue, 05 May 2015 20:15:58 GMT
Server: Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28
X-Powered-By: PHP/5.3.28
*******
Content-Type: text/html; charset=gbk
限制php解析
[root@localhost ~]# vi /usr/local/apache2/conf/extra/httpd-vhosts.conf
<Directory /data/www/path>
php_admin_flag engine off
<filesmatch "(.*)php">
Order deny,allow
Deny from all
</filesmatch>
</Directory>
[root@localhost www]# curl -x192.168.1.110:80 'http://www.123.com/path/1.php'
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h2>Forbidden</h2>
<p>You don't have permission to access /path/1.php
on this server.</p>
</body></html>
discuz偽靜態(tài)配置:
首先在論壇后臺的管理中心選擇全局-->SEO設置-->URL 靜態(tài)化選項上全部點勾-->提交
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.aaa.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.bbb.com$
RewriteRule ^/(.*)$ http://www.123.com/$1 [R=301,L]
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 ^/archiver/(fid|tid)-([0-9]+)\.html$ /archiver/index.php?action=$1&value=$2&%1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ /plugin.php?id=$1:$2&%1
</IfModule>
另外有需要云服務器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
網(wǎng)頁題目:apache的常用配置-創(chuàng)新互聯(lián)
網(wǎng)頁鏈接:http://jinyejixie.com/article8/diogip.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供關鍵詞優(yōu)化、手機網(wǎng)站建設、定制網(wǎng)站、網(wǎng)站設計、ChatGPT、微信公眾號
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容