EEDU Blog: 博客 ·  资讯 ·  论坛 ·  留言
登录 新用户? 注册   |  

ahaoxie's blog

订阅博客:

环境生态网站长

阅读全文

IIS 下实现 Drupal 简洁链接

推荐使用第三方程序 ISAPI。这个程序就是模拟 apache 下 rewrite 的功能,语法都完全一样。

首先去官网下载,当然是下载最新版的。其中,名称中有 _lite 的,是免费版本,另一个是收费版本。差别在于,收费版本支持每个目录一个配置文件,而免费版本,只有一个配置文件。

安装完成,打开 IIS 服务管理器,属性里查看 ISAPI 筛选器,不出意外,ISAPI 应该已经自动添加了。

如果没有,就点击添加,名称随意,可执行文件选择 ISAPI_Rewrite3 安装目录下的 dll 就行,例如:C:\Program Files\Helicon\ISAPI_Rewrite3\ISAPI_Rewrite.dll。

接下来就是设置伪静态规则了,直接从 Drupal 程序自带的 .htaccess 复制进来即可。复制关于简洁链接的那一段:

RewriteEngine on

#假设你的程序在根目录
RewriteBase /

#如果在子目录
#RewriteBase /drupal

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

新版本的 ISAPI_Rewrite,至少是 ISAPI_Rewrite3,是 httpd.conf 文件,直接在属性中打开编辑即可。

可能你的 IIS 下运行着很多网站,你只想针对某一个网站进行伪静态,那么最终的代码是这样的:

RewriteEngine on

#假设你的域名是 test.com,只想在这个域名下应用此静态规则。
#实际上里边的规则和 apache 下的 Rewrite 是一样的。
RewriteCond %{HTTP:Host} ^(?:www\.)?test\.com$

#假设你的程序在根目录
RewriteBase /

#如果在子目录
#RewriteBase /drupal

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

理论上,应该可以实现伪静态功能了。那么 IIS 7 呢?IIS 7已经自带类似的功能模块了。

来源:http://www.cmsns.com/group/node/26

发表于: 2010-10-29 00:06 | 全文(查看: 297) | 评论(0) | 本文地址 | 收藏 
分类: 服务器应用(148)   标签: drupal  新知  

"IIS 下实现 Drupal 简洁链接" 的评论: (共 0 条)

你对本文的评论:

登录后再作评论
Page was generated in 64 milliseconds