apache的常用配置

网友投稿 751 2022-09-22

apache的常用配置

apache的常用配置

域名跳转

[root@localhost ~]# vi  /usr/local/apache2/conf/extra/[OR]//注意空格         RewriteCond %{HTTP_HOST} ^bbb.com$         RewriteRule ^/(.*)$    

RewriteEngine on

RewriteCond %{HTTP_HOST} !^123.com$//注意空格

RewriteRule ^/(.*)$ [R=301,L]

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

[root@localhost ~]# curl -x127.0.0.1:80 123.com -IHTTP/1.1 301 Moved PermanentlyDate: Tue, 05 May 2015 18:40:12 GMTServer: Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28X-Powered-By: PHP/5.3.28location: forum.phpCache-Control: max-age=0Expires: Tue, 05 May 2015 18:40:12 GMTContent-Type: text/html[root@localhost ~]# curl -x127.0.0.1:80 aaa.com -IHTTP/1.1 301 Moved PermanentlyDate: Tue, 05 May 2015 18:40:21 GMTServer: Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28Location: ~]# vi  /usr/local/apache2/conf/extra/mod_headers.c>

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:80 123.com/static/js/logging.js -IHTTP/1.1 200 OKDate: Tue, 05 May 2015 18:59:19 GMTServer: Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28Last-Modified: Fri, 26 Dec 2014 01:49:42 GMTETag: "22a88-25b-50b14bd049980"Accept-Ranges: bytesContent-Length: 603cache-control: max-age=604800Content-Type: application/javascript

配置访问控制

[root@localhost ~]# vi  /usr/local/apache2/conf/extra/~]# vi  /usr/local/apache2/conf/extra///没有创建目录及文件导致错误HTTP/1.1 404 Not FoundDate: Tue, 05 May 2015 19:23:04 GMTServer: Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28Content-Type: text/html; charset=iso-8859-1

[root@localhost ~]# mkdir /data/~]# vi  /usr/local/apache2/conf/extra/text/html; charset=gbk

限制php解析

[root@localhost ~]# vi  /usr/local/apache2/conf/extra/静态化选项上全部点勾-->提交

RewriteEngine on

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

RewriteCond %{HTTP_HOST} ^bbb.com$

RewriteRule ^/(.*)$ [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

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:C# 命名规则(cctv5体育节目表)
下一篇:VSFTP配置 ------ 匿名用户与系统用户配置详解
相关文章

 发表评论

暂时没有评论,来抢沙发吧~