伪静态,针对windows2008,iis7的空间虚拟机
本文主要是针对虚拟主,配置为windows2008,iis7,如何进行进行伪静态设置,楼主用的空间虚拟主机已经成功。
操作方法
- 01
步骤一: “新建一个“chineseurl.php”文件,在里面写入以下代码,然后将文件上传到空间首页,如我的网站程序是放在wwwroot目录下,那么我就将这个文件放入wwwroot目录下。 chineseurl.php”文件代码如下: <?php// IIS Mod-Rewriteif (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];}// IIS Isapi_Rewriteelse if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];}else{// Use ORIG_PATH_INFO if there is no PATH_INFOif ( !isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO']) )$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];// Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)if ( isset($_SERVER['PATH_INFO']) ) {if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];else$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];}// Append the query string if it exists and isn't nullif (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];}}require("index.php");?>
- 02
步骤二 新建一个文件命名为web.config,在里面写入规则,(默认的标签前缀和分类目录前缀有更改的情况下,web.config规则如下:) 规则如下: <?xml version="1.0" encoding="UTF-8"?> <configuration><system.webServer><rewrite><rules><rule name="ChineseURL" stopProcessing="true"><match url="^(.*)$" /><conditions><add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /><add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /></conditions><action type="Rewrite" url="chineseurl.php"/></rule></rules></rewrite></system.webServer></configuration> 该文件也需要上传到空间首页。
- 03
步骤三 若默认的标签前缀和分类目录前缀有更改的情况下,web.config规则如下: <?xml version="1.0" encoding="UTF-8"?><configuration><system.webServer><rewrite><rules><rule name="ChineseURL" stopProcessing="true"><match url="^(tag|category)/(.*)$" /><action type="Rewrite" url="chineseurl.php"/></rule><rule name="wordpress" patternSyntax="Wildcard"><match url="*" /><conditions><add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /><add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /></conditions><action type="Rewrite" url="index.php" /></rule></rules></rewrite></system.webServer></configuration> 注意:“<match url=”^(tag|category)/(.*)$” />”需要根据实际目录来修改,假如安装在blog目录,则应改为“<match url=”^blog/(tag|category)/(.*)$” />” 标签前缀和分类目录名称根据实际目录修改。