如何使用php为windows服务器使用.htaccess ?

时间:2021-08-24 11:20:07

I want to implement .htaccess for URL rewrite. I am using windows server.

我想为URL重写实现.htaccess。我正在使用windows服务器。

I know there are two solutions:

我知道有两个解决方案:

  1. using webconfig

    使用webconfig

  2. using Helicon

    使用螺旋形

I dont know how to write .htaccess code in webconfig file and I dont want to use Helicon because this is paid.

我不知道如何在webconfig文件中编写.htaccess代码,我也不想使用Helicon,因为这是付费的。

The code I want to implement in the webconfig file is :

我想在webconfig文件中实现的代码是:

    AddType application/x-httpd-php .html
    RewriteEngine on

    <IfModule mod_rewrite.c>

    RewriteCond %{Request_Filename} !-d
    RewriteCond %{Request_Filenam}e !-f

    RewriteRule ^privacy  privacy.html [NC]
    RewriteRule ^dating-articles dating-articles.html [NC]
    RewriteRule ^articles/([0-9A-Za-z_\-~',]+)    article_detail.html?article_link=$1 [NC]
    RewriteRule ^([a-zA-Z0-9_-]+)$ page.php?page_slug=$1  [NC]

    </IfModule>

Thanks in advance.

提前谢谢。

1 个解决方案

#1


-1  

Windows 2012 and 2008 both have url rewrites. Just open your site in the information manager and in the center plane, hit the url rewrite to open it. just add this in the inbound window.

Windows 2012和2008都有url重写。在信息管理器中打开你的站点,在中心平面中,点击url重写以打开它。在入站窗口中添加这个。

RewriteCond %{Request_Filename} !-d
RewriteCond %{Request_Filenam}e !-f
RewriteRule ^privacy  privacy.html [NC]
RewriteRule ^dating-articles dating-articles.html [NC]
RewriteRule ^articles/([0-9A-Za-z_\-~',]+)    article_detail.html?     article_link=$1 [NC]
RewriteRule ^([a-zA-Z0-9_-]+)$ page.php?page_slug=$1  [NC]

#1


-1  

Windows 2012 and 2008 both have url rewrites. Just open your site in the information manager and in the center plane, hit the url rewrite to open it. just add this in the inbound window.

Windows 2012和2008都有url重写。在信息管理器中打开你的站点,在中心平面中,点击url重写以打开它。在入站窗口中添加这个。

RewriteCond %{Request_Filename} !-d
RewriteCond %{Request_Filenam}e !-f
RewriteRule ^privacy  privacy.html [NC]
RewriteRule ^dating-articles dating-articles.html [NC]
RewriteRule ^articles/([0-9A-Za-z_\-~',]+)    article_detail.html?     article_link=$1 [NC]
RewriteRule ^([a-zA-Z0-9_-]+)$ page.php?page_slug=$1  [NC]