简体   繁体   English

ISAPI重写检测根文件夹

[英]ISAPI Rewrite detect root folder

Using ISAPI Rewrite I'm looking for a way to detect if a given URL contains only one subfolder and then rewriting the URL. 使用ISAPI重写我正在寻找一种方法来检测给定的URL是否仅包含一个子文件夹,然后重写URL。

www.mysite.com/Cloud     => true
www.mysite.com/Cloud/    => false
www.mysite.com/Cloud/One => false
www.mysite.com/Cloud.xml => false

the result should be the URL added with .html only for the true condition 结果应该是仅在真实条件下添加.html的URL

www.mysite.com/Cloud.html

Try using the following: 尝试使用以下内容:

RewriteEngine on
RewriteBase /

RewriteRule ^([^/]+)$ $1.html [NC,L]

You did not specify if it's a 301-redirect or a rewrite. 您未指定是301重定向还是重写。 So in case it's 301-redirect, simply add R=301 in flags. 因此,如果是301重定向,只需在标记中添加R = 301。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM