将 .htaccess 转换为 web.config
我在运行 IIS 的虚拟 Windows 服务器上托管一个 php 应用程序。
为我编写php网站的人要求我将这段代码放在.htaccess中:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
但是由于该应用程序在IIS上运行,因此我需要将这段代码翻译为web.config。我怎样才能将它们翻译成web.config?
I am hosting a php application on my virtual Windows server running IIS.
The person who wrote the php website for me asked me to put this piece of codes in a .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
But as this application is running on IIS, I need to translate this piece of codes to web.config. How can I translate them into web.config?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此 htaccess 代码的作用是将任何可能导致 404 错误(!-f 和 !-d 表示“文件不存在”和“目录不存在”)的请求重定向到 /index.php。
IIS7 具有导入 mod_rewrite 规则的功能 - 只需使用此功能:
(来源)
What this htaccess code does is redirecting any requests which would otherwise result in a 404 error (!-f and !-d mean "file does not exist" and "dir does not exist") to /index.php.
IIS7 has a feature to import mod_rewrite rules - simply use this:
(Source)