search
HomeBackend DevelopmentPHP Tutorialapache主机伪静态规则.htaccess转为web.config的方法

.htacess文件是apache下面的伪静态文件,nginx环境下,这个文件经过简单设置后同样有效;如果是windows 2003,实际 上程序提供商会同时提供apache和windows 2003下面的伪静态文件,我们不必担心。如果用的是IIS 7或IIS 7.5,这下面的伪 静态文件是web.config文件,那么要怎么把.htacess文件转换为web.config文件呢?

这是前段时间我遇到的问题,花钱买了一个程序,程序商没有提供web.config伪静态文件,找他要,他说他不知道咋弄, 要我自己去弄;我只好去淘宝网找人弄,随便找了个店家,问了问,开口要价200元,都快把我噎住了,不到20句伪静态转换居 然要200元?换了好几家店铺,没有一家低于150元,因此还是觉得自己弄!

上网查找了很多的资料,终于找到了很简单的解决方法,只要几分钟即可搞定,完全不必花费几十元甚至上百元让人来弄 。这个方法的解决方法是Urlrewrite插件,这是地址重写插件,安装以后可以加载到IIS7及IIS7.5面板上面,我们直接用这个 插件的功能即可把.htacess伪静态文件转换为.webconfig文件。

下载安装Urlrewrite插件

这个插件默认不集成在IIS7及7.5上面,要网友自己去下载安装,目前的版本是URL Rewrite 2.0,安装完成以后,重启IIS  7或IIS 7.5,选择自己的网站,那么会看到Urlrewrite模块,这是全英文的。安装方法很简单,按默认配置安装即可,不用修改安装文件的地址。

下载地址:http://www.iis.net/extensions/urlrewrite

进入使用Urlrewrite插件

进入服务器管理器,选择“Internet信息服务”-“起始页”-“自己的网站”,哪个网站要使用伪静态,那么进入到哪个网 站,点击网站名即可进入到对应的网站控制面板,选择Urlrewrite模块即可,进入以后即可看到Urlrewrite全英文的界面。

转换.htacess伪静态文件

如果要转换.htacess伪静态文件,那么选择Import mod_rewrite Rules,即是右边区域第三行黑字下面的选项,点击即可 进入,进入以后会看到相应的对话框,我们点击上面输入框右侧的按钮,选择.htacess伪静态文件,再点击上面输入框下面的 Import即可导入,导入以后,我们会在Rewrite rules看到导入成功的伪静态规则,选择右边的操作-应用即可。

转换.webconfig文件成功

IIS7及IIS7.5下面是不支持直接用.htacess伪静态文件的,伪静态文件都要变换为web.config文件,实际上经过上面的导 入操作,我们去网站目录,会发现网站的web.config文件已经有很多伪静态规则。这时你要去做的是检查伪静态规则是否正确 ,理论上只要是标注的.htacess伪静态文件,那么导入以后都会准确的。

上面的操作只要几分钟时间,不过当初我查找相关的资料,还是花费掉好几小时,因此写成本文,希望对使用IIS 7及IIS  7.5的站长有所帮助;当然,如果是虚拟主机遇到伪静态规则问题,直接联系空间商即可,空间商会处理好一切的。


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
11 Best PHP URL Shortener Scripts (Free and Premium)11 Best PHP URL Shortener Scripts (Free and Premium)Mar 03, 2025 am 10:49 AM

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Working with Flash Session Data in LaravelWorking with Flash Session Data in LaravelMar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

Build a React App With a Laravel Back End: Part 2, ReactBuild a React App With a Laravel Back End: Part 2, ReactMar 04, 2025 am 09:33 AM

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Simplified HTTP Response Mocking in Laravel TestsSimplified HTTP Response Mocking in Laravel TestsMar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

cURL in PHP: How to Use the PHP cURL Extension in REST APIscURL in PHP: How to Use the PHP cURL Extension in REST APIsMar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

12 Best PHP Chat Scripts on CodeCanyon12 Best PHP Chat Scripts on CodeCanyonMar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Announcement of 2025 PHP Situation SurveyAnnouncement of 2025 PHP Situation SurveyMar 03, 2025 pm 04:20 PM

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

Notifications in LaravelNotifications in LaravelMar 04, 2025 am 09:22 AM

In this article, we're going to explore the notification system in the Laravel web framework. The notification system in Laravel allows you to send notifications to users over different channels. Today, we'll discuss how you can send notifications ov

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),