{"id":641,"date":"2015-10-12T09:03:15","date_gmt":"2015-10-12T01:03:15","guid":{"rendered":"http:\/\/www.yusian.com\/blog\/?p=641"},"modified":"2016-07-16T14:38:44","modified_gmt":"2016-07-16T06:38:44","slug":"centos-%e6%b7%bb%e5%8a%a0%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%bavirtualhost%e5%8f%8a%e4%bc%aa%e9%9d%99%e6%80%81rewrite","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/centos\/2015\/10\/12\/090315641.html","title":{"rendered":"CentOS \u6dfb\u52a0\u865a\u62df\u4e3b\u673aVirtualHost\u53ca\u4f2a\u9759\u6001Rewrite"},"content":{"rendered":"<p>1\u3001\u627e\u5230Apache\u7684\u914d\u7f6e\u6587\u4ef6 \/etc\/httpd\/conf\/httpd.conf<\/p>\n<p>2\u3001\u627e\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u4ee5\u4e0b\u4ee3\u7801<\/p>\n<p>LoadModule vhost_alias_module modules\/mod_vhost_alias.so<\/p>\n<p>\u5982\u679c\u524d\u9762\u6709#\u53f7\u6ce8\u91ca\uff0c\u53bb\u6389#\u53f7\u6ce8\u91ca\uff0c\u8fd9\u4ee3\u8868\u662f\u5426\u5f00\u542f\u865a\u62df\u4e3b\u673a\u670d\u52a1<\/p>\n<p>3\u3001\u627e\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u4ee5\u4e0b\u4ee3\u7801\uff0c\u4e00\u822c\u5728\u914d\u7f6e\u6587\u4ef6\u7684\u6700\u672b\u5c3e\u90e8\u5206<\/p>\n<pre line=\"1\">#\n# Use name-based virtual hosting.\n#\n#NameVirtualHost *:80\n#\n# NOTE: NameVirtualHost cannot be used without a port specifier \n# (e.g. :80) if mod_ssl is being used, due to the nature of the\n# SSL protocol.\n#\n\n#\n# VirtualHost example:\n# Almost any Apache directive may go into a VirtualHost container.\n# The first VirtualHost section is used for requests without a known\n# server name.\n#\n#<VirtualHost *:80>\n#    ServerAdmin webmaster@dummy-host.example.com\n#    DocumentRoot \/www\/docs\/dummy-host.example.com\n#    ServerName dummy-host.example.com\n#    ErrorLog logs\/dummy-host.example.com-error_log\n#    CustomLog logs\/dummy-host.example.com-access_log common\n#<\/VirtualHost><\/pre>\n<p>\u9700\u8981\u7528\u5230\u7684\u90e8\u5206\u6709<!--more--><\/p>\n<pre line=\"1\">#########################################################\n#NameVirtualHost *:80\n\n#<VirtualHost *:80>\n#    ServerAdmin webmaster@dummy-host.example.com\n#    DocumentRoot \/www\/docs\/dummy-host.example.com\n#    ServerName dummy-host.example.com\n#    ErrorLog logs\/dummy-host.example.com-error_log\n#    CustomLog logs\/dummy-host.example.com-access_log common\n#<\/VirtualHost>\n#########################################################<\/pre>\n<p>\u628a\u524d\u9762\u7684#\u53bb\u6389\u6216\u8005\u6309\u7167\u8fd9\u4e2a\u683c\u5f0f\u5199\u4e00\u4efd<\/p>\n<pre line=\"1\">ServerAdmin         \/\/ \u7f51\u7ad9\u7528\u4e8e\u63a5\u6536\u4fe1\u606f\u90ae\u7bb1\u5730\u5740\uff0c\u975e\u5fc5\u586b\nDocumentRoot        \/\/ \u7f51\u7ad9\u6587\u4ef6\u6240\u5728\u7684\u7edd\u5bf9\u8def\u5f84\uff0c\u76f8\u5bf9\u4e8e\u670d\u52a1\u5668\u7684\u6839\uff0c\u4e0d\u662fApache\u7684\u6839\uff0c\u5fc5\u586b\uff01\nServerName          \/\/ \u6570\u636e\u8bf7\u6c42\u7684\u57df\u540d\uff0c\u5b9e\u73b0\u540c\u4e00\u53f0\u670d\u52a1\u5668\uff0c\u540c\u4e00\u4e2aApache\u670d\u52a1\uff0c\u4e0d\u540c\u57df\u540d\u8df3\u8f6c\u5230\u4e0d\u540c\u7f51\u7ad9\uff0c\u5fc5\u586b\uff01\nErrorLog            \/\/ \u65e5\u5fd7\u6587\u4ef6\uff0c\u975e\u5fc5\u586b\nCustomLog           \/\/ \u65e5\u5fd7\u6587\u4ef6\uff0c\u975e\u5fc5\u586b<\/pre>\n<p>4\u3001\u5982\u679c\u6709\u4f2a\u9759\u6001\uff0c\u5982Discuz\u7684\u4f2a\u9759\u6001<\/p>\n<pre line=\"1\"><IfModule mod_rewrite.c>\n        RewriteEngine On\n        RewriteCond %{QUERY_STRING} ^(.*)$\n        RewriteRule ^(.*)\/topic-(.+)\\.html$ $1\/portal.php?mod=topic&topic=$2&%1\n        RewriteCond %{QUERY_STRING} ^(.*)$\n        RewriteRule ^(.*)\/article-([0-9]+)-([0-9]+)\\.html$ $1\/portal.php?mod=view&aid=$2&page=$3&%1\n        RewriteCond %{QUERY_STRING} ^(.*)$\n        RewriteRule ^(.*)\/forum-(\\w+)-([0-9]+)\\.html$ $1\/forum.php?mod=forumdisplay&fid=$2&page=$3&%1\n        RewriteCond %{QUERY_STRING} ^(.*)$\n        RewriteRule ^(.*)\/thread-([0-9]+)-([0-9]+)-([0-9]+)\\.html$ $1\/forum.php?mod=viewthread&tid=$2&extra=page\\%3D$4&page=$3&%1\n        RewriteCond %{QUERY_STRING} ^(.*)$\n        RewriteRule ^(.*)\/group-([0-9]+)-([0-9]+)\\.html$ $1\/forum.php?mod=group&fid=$2&page=$3&%1\n        RewriteCond %{QUERY_STRING} ^(.*)$\n        RewriteRule ^(.*)\/space-(username|uid)-(.+)\\.html$ $1\/home.php?mod=space&$2=$3&%1\n        RewriteCond %{QUERY_STRING} ^(.*)$\n        RewriteRule ^(.*)\/blog-([0-9]+)-([0-9]+)\\.html$ $1\/home.php?mod=space&uid=$2&do=blog&id=$3&%1\n        RewriteCond %{QUERY_STRING} ^(.*)$\n        RewriteRule ^(.*)\/(fid|tid)-([0-9]+)\\.html$ $1\/index.php?action=$2&value=$3&%1\n        RewriteCond %{QUERY_STRING} ^(.*)$\n        RewriteRule ^(.*)\/([a-z]+[a-z0-9_]*)-([a-z0-9_\\-]+)\\.html$ $1\/plugin.php?id=$2:$3&%1\n<\/IfModule><\/pre>\n<p>\u5e94\u8be5\u52a0\u5728VirtualHost\u4f5c\u7528\u57df\u5185<\/p>\n<pre line=\"1\"><VirtualHost *:80>\n\/\/ \u4f2a\u9759\u6001\u4ee3\u7801\n<\/VirtualHost><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u627e\u5230Apache\u7684\u914d\u7f6e\u6587\u4ef6 \/etc\/httpd\/conf\/httpd.conf 2\u3001\u627e\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u4ee5\u4e0b\u4ee3\u7801 LoadModule vhost_alias_module modules\/mod_vhost_alias.so \u5982\u679c\u524d\u9762\u6709#\u53f7\u6ce8\u91ca\uff0c\u53bb\u6389#\u53f7\u6ce8\u91ca\uff0c\u8fd9\u4ee3\u8868\u662f\u5426\u5f00\u542f\u865a\u62df\u4e3b\u673a\u670d\u52a1 3\u3001\u627e\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u4ee5\u4e0b\u4ee3\u7801\uff0c\u4e00\u822c\u5728\u914d\u7f6e\u6587\u4ef6\u7684\u6700\u672b\u5c3e\u90e8\u5206 # # Use name-based virtual hosting. # #NameVirtualHost *:80 # # NOTE: NameVirtualHost cannot be used without a port specifier # (e.g. :80) if mod_ssl is being used, due to the nature of the # SSL protocol. # # # VirtualHost example: # Almost any Apache directive [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[7,8],"class_list":["post-641","post","type-post","status-publish","format-standard","hentry","category-centos","tag-apache","tag-linux"],"_links":{"self":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/641","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/comments?post=641"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/641\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=641"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=641"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}