[提问]
谁能替我将.htaccess 转换成web.config文件?
|
|
.htaccess 代码如下
# Prevent .htaccess and .htpasswd files from being viewed by web clients
<Files "^\.ht">
Order allow,deny
Deny from all
</Files>
# Protect files
<Files ~ "^(.*)\.(inc|inc\.php|tpl|sql)$">
Order deny,allow
Deny from all
</Files>
# Protect directories
<Files ~ "^(backup|files|images|include|lang|libs(/.+)?|temp(/.+)?|templates(/.+)?|javascripts(/.+)?)$">
Order deny,allow
Deny from all
</Files>
# Disable directory browsing
Options -Indexes
# Follow symbolic links in this directory
Options +FollowSymLinks
# Override PHP settings that cannot be changed at runtime
# (If your server supports PHP settings via htaccess you can comment following two lines off)
# php_value register_globals 0
# php_value session.auto_start 0
# Customized error messages
# ( If you are running in a subfolder please add it, example: "directory/index.php?httpstatus=404" )
ErrorDocument 404 index.php?httpstatus=404
# Set the default handler
DirectoryIndex index.php
# URL rewrite rules
<IfModule mod_rewrite.c>
RewriteEngine On
#Make sure RewriteBase points to the directory where you installed phpLD.
#Example: "/phpld" if your installation is in a "phpld" subdirectory.
#RewriteBase /
##Latest Links Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^latest-links\.htm[l]?$ index.php?list=latest [QSA,NC,L]
##Top Hits Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^top-hits\.htm[l]?$ index.php?list=top [QSA,NC,L]
##Latest Articles Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^latest-articles\.htm[l]?$ index.php?list=latestarticles [QSA,NC,L]
##Details Link Page Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule (.*)detail/(.*)$ detail.php?id=$2 [QSA,NC]
##Article Page Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule (.*)articles/(.*)$ article.php?id=$2 [QSA,NC]
##Author Page Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule (.*)authors/author-(.*)\.htm[l]?$ author.php [QSA,NC]
##Owner Page Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule (.*)owner/owner-(.*)\.htm[l]?$ author.php [QSA,NC]
##Pagination Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule (.*)page-[0-9]+\.html$ index.php [QSA,NC,L]
##Pages redirect
RewriteCond %{REQUEST_URI} !page-[0-9]+\.html?$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)\.html$ page.php?name=$1 [NC,QSA,L]
RewriteRule ^(.*)loadingAnimation.gif$ javascripts/thickbox/loadingAnimation.gif
##Category redirect
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule> |
|
|
|
|
|
|
|
|
|
|
lwbo1987
发表于 2011-12-15 16:11:43
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
JJ2008JJ
发表于 2011-12-15 16:18:04
|
显示全部楼层
|
网上有软件,不过是要在win7 或vista上安装IIS7.0才可以运行,我的是winxp,没办法,只要求助了 |
|
|
|
|
|
|
|
|
|
|
lwbo1987
发表于 2011-12-15 16:20:06
|
显示全部楼层
回复 3# 的帖子
|
看看是否有在线转换的,代码转换了其实还需要自己修改的,不一定完全正确的 |
|
|
|
|
|
|
|
|
|
|
JJ2008JJ
发表于 2011-12-15 16:42:54
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
lwbo1987
发表于 2011-12-15 17:37:27
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
JJ2008JJ
发表于 2011-12-15 18:30:55
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
JJ2008JJ
发表于 2011-12-16 09:19:43
|
显示全部楼层
.htaccess 代码 是
##Latest Links Rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^latest-links\.htm[l]?$ index.php?list=latest [QSA,NC,L]
转换后web.config中对应的代码是
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^latest-links\.htm[l]?$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
???????????????
</conditions>
参考 http://httpd.apache.org/docs/current/mod/mod_rewrite.html ,-l
'-d' (is directory)
Treats the TestString as a pathname and tests whether or not it exists, and is a directory.'-f' (is regular file)
Treats the TestString as a pathname and tests whether or not it exists, and is a regular file.'-l' (is symbolic link)
Treats the TestString as a pathname and tests whether or not it exists, and is a symbolic link.
-f 转变为 IsFile, -d 转变为 IsDirectory ,问题就是 RewriteCond %{REQUEST_FILENAME} !-l 中的 " -I " 识别不了? -I 转变为什么呢?
那么,RewriteCond %{REQUEST_FILENAME} !-l 这句话怎么编译? |
|
|
|
|
|
|
|
|
|
|
JJ2008JJ
发表于 2011-12-16 16:01:25
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
lwbo1987
发表于 2011-12-16 16:11:44
|
显示全部楼层
|
|
|
|
|
|
|
|