[root@Kry123 ~]# curl -x192.168.0.123:80 -I www.kry1702.com/forum.php
HTTP/1.1 404 Not Found
Date: Tue, 14 Jun 2016 07:57:03 GMT
Server: Apache/2.4.20 (Unix)
Content-Type: text/html; charset=iso-8859-1
[root@Kry123 ~]# curl -x192.168.0.123:80 -I www.kry1702.com/
HTTP/1.1 301 Moved Permanently
Date: Tue, 14 Jun 2016 07:57:18 GMT
Server: Apache/2.4.20 (Unix) PHP/5.6.22
X-Powered-By: PHP/5.6.22
location: forum.php
Content-Type: text/html; charset=UTF-8
[root@Kry123 ~]# curl -x192.168.0.123:80 -I www.kry1702.com/forum.php
HTTP/1.1 301 Moved Permanently
Date: Tue, 14 Jun 2016 07:57:24 GMT
Server: Apache/2.4.20 (Unix) PHP/5.6.22
Location: http://www.kry.com/forum.php
Cache-Control: max-age=0
Expires: Tue, 14 Jun 2016 07:57:24 GMT
Content-Type: text/html; charset=iso-8859-1
为什么先访问报错404,然后在让问就是301了喃。。。
HTTP/1.1 404 Not Found
Date: Tue, 14 Jun 2016 07:57:03 GMT
Server: Apache/2.4.20 (Unix)
Content-Type: text/html; charset=iso-8859-1
[root@Kry123 ~]# curl -x192.168.0.123:80 -I www.kry1702.com/
HTTP/1.1 301 Moved Permanently
Date: Tue, 14 Jun 2016 07:57:18 GMT
Server: Apache/2.4.20 (Unix) PHP/5.6.22
X-Powered-By: PHP/5.6.22
location: forum.php
Content-Type: text/html; charset=UTF-8
[root@Kry123 ~]# curl -x192.168.0.123:80 -I www.kry1702.com/forum.php
HTTP/1.1 301 Moved Permanently
Date: Tue, 14 Jun 2016 07:57:24 GMT
Server: Apache/2.4.20 (Unix) PHP/5.6.22
Location: http://www.kry.com/forum.php
Cache-Control: max-age=0
Expires: Tue, 14 Jun 2016 07:57:24 GMT
Content-Type: text/html; charset=iso-8859-1
为什么先访问报错404,然后在让问就是301了喃。。。
0
也没修改那些地方啊
虚拟主机
301跳转
日志分割
不记录文件类型日志
防盗链
阿铭 发表于 2016-6-14 21:30
你修改过啥地方吗?我看你两次不同:
Server: Apache/2.4.20 (Unix)
Server: Apache/2.4.20 (Unix) PHP/ ...
也没修改那些地方啊
虚拟主机
301跳转
日志分割
不记录文件类型日志
防盗链
0
本帖最后由 Kry1702 于 2016-6-15 00:10 编辑
httpd 主配置文件
[root@Kry123 ~]# cat /usr/local/apache/conf/httpd.conf |grep -v "^#
ServerRoot "/usr/local/apache"
Listen 80
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module modules/libphp5.so
User daemon
Group daemon
ServerAdmin you@example.com
ServerName localhost:80
AllowOverride none
Require all denied
AllowOverride none
Require all granted
DocumentRoot "/usr/local/apache/htdocs"
#
# 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.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
DirectoryIndex index.html index.htm index.php
Require all denied
ErrorLog "logs/error_log"
LogLevel warn
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
#
# The location and format of the access logfile (Common Logfile Format).
# If you do not define any access logfiles within a
# container, they will be logged here. Contrariwise, if you *do*
# define per- access logfiles, transactions will be
# logged therein and *not* in this file.
#
CustomLog "logs/access_log" common
#
# If you prefer a logfile with access, agent, and referer information
# (Combined Logfile Format) you can use the following directive.
#
#CustomLog "logs/access_log" combined
#
# Redirect: Allows you to tell clients about documents that used to
# exist in your server's namespace, but do not anymore. The client
# will make a new request for the document at its new location.
# Example:
# Redirect permanent /foo http://www.example.com/bar
#
# Alias: Maps web paths into filesystem paths and is used to
# access content that does not live under the DocumentRoot.
# Example:
# Alias /webpath /full/filesystem/path
#
# If you include a trailing / on /webpath then the server will
# require it to be present in the URL. You will also likely
# need to provide a section to allow access to
# the filesystem path.
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the target directory are treated as applications and
# run by the server when requested rather than as documents sent to the
# client. The same rules about trailing "/" apply to ScriptAlias
# directives as to Alias.
#
ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"
#
# ScriptSock: On threaded servers, designate the path to the UNIX
# socket used to communicate with the CGI daemon of mod_cgid.
#
#Scriptsock cgisock
AllowOverride None
Options None
Require all granted
#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig conf/mime.types
#
# AddType allows you to add to or override the MIME configuration
# file specified in TypesConfig for specific file types.
#
#AddType application/x-gzip .tgz
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
#
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
#
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
#AddHandler cgi-script .cgi
# For type maps (negotiated resources):
#AddHandler type-map var
#
# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
#AddType text/html .shtml
#AddOutputFilter INCLUDES .shtml
Include conf/extra/httpd-vhosts.conf
Include conf/extra/proxy-html.conf
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
httpd 主配置文件
[root@Kry123 ~]# cat /usr/local/apache/conf/httpd.conf |grep -v "^#
ServerRoot "/usr/local/apache"
Listen 80
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module modules/libphp5.so
User daemon
Group daemon
ServerAdmin you@example.com
ServerName localhost:80
AllowOverride none
Require all denied
AllowOverride none
Require all granted
DocumentRoot "/usr/local/apache/htdocs"
#
# 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.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
DirectoryIndex index.html index.htm index.php
Require all denied
ErrorLog "logs/error_log"
LogLevel warn
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
#
# The location and format of the access logfile (Common Logfile Format).
# If you do not define any access logfiles within a
# container, they will be logged here. Contrariwise, if you *do*
# define per-
# logged therein and *not* in this file.
#
CustomLog "logs/access_log" common
#
# If you prefer a logfile with access, agent, and referer information
# (Combined Logfile Format) you can use the following directive.
#
#CustomLog "logs/access_log" combined
#
# Redirect: Allows you to tell clients about documents that used to
# exist in your server's namespace, but do not anymore. The client
# will make a new request for the document at its new location.
# Example:
# Redirect permanent /foo http://www.example.com/bar
#
# Alias: Maps web paths into filesystem paths and is used to
# access content that does not live under the DocumentRoot.
# Example:
# Alias /webpath /full/filesystem/path
#
# If you include a trailing / on /webpath then the server will
# require it to be present in the URL. You will also likely
# need to provide a
# the filesystem path.
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the target directory are treated as applications and
# run by the server when requested rather than as documents sent to the
# client. The same rules about trailing "/" apply to ScriptAlias
# directives as to Alias.
#
ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"
#
# ScriptSock: On threaded servers, designate the path to the UNIX
# socket used to communicate with the CGI daemon of mod_cgid.
#
#Scriptsock cgisock
AllowOverride None
Options None
Require all granted
#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig conf/mime.types
#
# AddType allows you to add to or override the MIME configuration
# file specified in TypesConfig for specific file types.
#
#AddType application/x-gzip .tgz
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
#
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
#
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
#AddHandler cgi-script .cgi
# For type maps (negotiated resources):
#AddHandler type-map var
#
# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
#AddType text/html .shtml
#AddOutputFilter INCLUDES .shtml
Include conf/extra/httpd-vhosts.conf
Include conf/extra/proxy-html.conf
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
0
虚拟主机配置
[root@Kry123 ~]# cat /usr/local/apache/conf/extra/httpd-vhosts.conf |grep -v "^#"
DocumentRoot "/tmp/web/"
ServerName 123.com
DocumentRoot "/data/www/discuz/"
ServerName www.kry.com
ServerAlias www.kry1702.com
setEnvIf Request_URI ".*\.gif$" image-request
setEnvIf Request_URI ".*\.jpg$" image-request
setEnvIf Request_URI ".*\.png$" image-request
setEnvIf Request_URI ".*\.bmp$" image-request
setEnvIf Request_URI ".*\.js$" image-request
setEnvIf Request_URI ".*\.css$" image-request
ErrorLog "|/usr/local/apache/bin/rotatelogs -l /usr/local/apache/logs/kry.com/kry.com_error_%Y%m%d_log 86400"
CustomLog "|/usr/local/apache/bin/rotatelogs -l /usr/local/apache/logs//kry.com/kry.com_access_%Y%m%d_log 86400" combined
AllowOverride None
Options None
Order allow,deny
Allow from all
Order deny,allow
#Deny from all
Allow from all
php_admin_flag engine off
Order deny,allow
Deny from all
setEnvIfNoCase Refere "^http://.*\.kry\.com" local_ref
setEnvIfNoCase Refere "^http://.*\.kry1702\.com" local_ref
Order Allow,Deny
Allow from env=local_ref
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.kry1702.com$
RewriteRule ^/(.*)$ http://www.kry.com/$1 [R=301,L]
AllowOverride AuthConfig
AuthName "abc"
AuthType Basic
AuthUserFile /data/.passwd
require valid-user
[root@Kry123 ~]# cat /usr/local/apache/conf/extra/httpd-vhosts.conf |grep -v "^#"
DocumentRoot "/tmp/web/"
ServerName 123.com
DocumentRoot "/data/www/discuz/"
ServerName www.kry.com
ServerAlias www.kry1702.com
setEnvIf Request_URI ".*\.gif$" image-request
setEnvIf Request_URI ".*\.jpg$" image-request
setEnvIf Request_URI ".*\.png$" image-request
setEnvIf Request_URI ".*\.bmp$" image-request
setEnvIf Request_URI ".*\.js$" image-request
setEnvIf Request_URI ".*\.css$" image-request
ErrorLog "|/usr/local/apache/bin/rotatelogs -l /usr/local/apache/logs/kry.com/kry.com_error_%Y%m%d_log 86400"
CustomLog "|/usr/local/apache/bin/rotatelogs -l /usr/local/apache/logs//kry.com/kry.com_access_%Y%m%d_log 86400" combined
AllowOverride None
Options None
Order allow,deny
Allow from all
Order deny,allow
#Deny from all
Allow from all
php_admin_flag engine off
Order deny,allow
Deny from all
setEnvIfNoCase Refere "^http://.*\.kry\.com" local_ref
setEnvIfNoCase Refere "^http://.*\.kry1702\.com" local_ref
Order Allow,Deny
Allow from env=local_ref
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.kry1702.com$
RewriteRule ^/(.*)$ http://www.kry.com/$1 [R=301,L]
AllowOverride AuthConfig
AuthName "abc"
AuthType Basic
AuthUserFile /data/.passwd
require valid-user
编辑回复