Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Common configurations of apache

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Domain name jump

[root@localhost ~] # vi / usr/local/apache2/conf/extra/httpd-vhosts.conf

* *

RewriteEngine on

RewriteCond% {HTTP_HOST} ^ www.aaa.com$ [OR] / / pay attention to the spaces

RewriteCond% {HTTP_HOST} ^ www.bbb.com$

RewriteRule ^ / (. *) $http://www.123.com/$1 [Rust 301m L]

Or:

RewriteEngine on

RewriteCond {HTTP_HOST}! ^ www.123.com$// pay attention to the spaces

RewriteRule ^ / (. *) $http://www.123.com/$1 [Rust 301m L]

************************

[root@localhost] # curl-x127.0.0.1 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 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 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

Configure static file caching

[root@localhost ~] # vi / usr/local/apache2/conf/extra/httpd-vhosts.conf

Header set cache-control "max-age=3600"

Header set cache-control "max-age=604800"

Header set cache-control "max-age=29030400"

[root@localhost] # curl-x127.0.0.1 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

Configure access control

[root@localhost ~] # vi / usr/local/apache2/conf/extra/httpd-vhosts.conf

Order deny,allow

Deny from all

Allow from 127.0.0.1

[root@localhost] # curl-x192.168.1.110 www.123.com/1.txt 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 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

This configuration will result in inaccessibility to the site, which is not allowed at work, and is generally applied to important directories that prohibit access to the site.

Access to a directory is prohibited:

[root@localhost ~] # vi / usr/local/apache2/conf/extra/httpd-vhosts.conf

Order deny,allow

Deny from all

Allow from 127.0.0.1

[root@localhost ~] # curl-x127.0.0.1 www.123.com/admin/1.txt-I / / failure to create directory and file caused error

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 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 www.123.com/admin/1.txt 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

Prohibit access to a file

[root@localhost ~] # vi / usr/local/apache2/conf/extra/httpd-vhosts.conf

Order deny,allow

Deny from all

Allow from 127.0.0.1

[root@localhost] # curl-x192.168.1.110 www.123.com/admin.phpsfsafa 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 www.123.com/admin.php 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 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

Restrict php parsing

[root@localhost ~] # vi / usr/local/apache2/conf/extra/httpd-vhosts.conf

Php_admin_flag engine off

Order deny,allow

Deny from all

[root@localhost www] # curl-x192.168.1.110 curl 80 'http://www.123.com/path/1.php'

403 Forbidden

Forbidden

You don't have permission to access / path/1.php

On this server.

Discuz pseudo-static configuration:

First of all, select global-> SEO settings-- > URL static options on all the ticks-- > submit in the console at the background of the forum.

RewriteEngine on

RewriteCond% {HTTP_HOST} ^ www.aaa.com$ [OR]

RewriteCond% {HTTP_HOST} ^ www.bbb.com$

RewriteRule ^ / (. *) $http://www.123.com/$1 [Rust 301m 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 Merz] + [a-z0-9 _] *)-([a-z0-9 _\ -] +)\ .html $/ plugin.php?id=$1:$2&%1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report