我遇到问题similer到this post
我试过这个
RewriteCond %{HTTP_HOST} ^myApplication.com
RewriteCond %{REQUEST_URI} !myApplication/
RewriteRule ^(.*)$ myApplication/$1 [L]
RewriteCond %{HTTP_HOST} www.myApplication.com
RewriteCond %{REQUEST_URI} !myApplication/
RewriteRule ^(.*)$ myApplication/$1 [L]
但问题是url仅适用于www.myApplication.com/myApplication,但我想隐藏myApplication子文件夹。 我真的很感激你的帮助。
更新: 我试过这个给出了500个服务器错误。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="mod_rewrite" path="*" verb="*" modules="IsapiModule" scriptProcessor="path to scriptproc" resourceType="Unspecified" requireAccess="None" preCondition="bitness32" />
</handlers>
<rule name="Rewrite to myApplicaton" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www\.)myApplication\.com$" />
<add input="{REQUEST_URI}" pattern="^myApplication/" negate="true" />
</conditions>
<action type="Rewrite" url="/myApplication/{R:0}" />
</rule>
</system.webServer>
</configuration>
答案 0 :(得分:1)
以下应该做你想做的事:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite to myApplicaton" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www\.)myApplication\.com$" />
<add input="{REQUEST_URI}" pattern="^myApplication/" negate="true" />
</conditions>
<action type="Rewrite" url="/myApplication/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>