Using ISAPI Rewrite I'm looking for a way to detect if a given URL contains only one subfolder and then rewriting the 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

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. So in case it's 301-redirect, simply add R=301 in flags.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top