Iis 7 如何显示自定义页面URL?

Iis 7 如何显示自定义页面URL?,iis-7,url-rewrite-module,Iis 7,Url Rewrite Module,让我举例说明: 每当有人在我的网站上开户时,他/她也会创建一个店铺ID,如MyHawaiiSpa。一旦生成存储ID,则无法更改它。在此,我假设此帐户的pkid为1 现在,访问者点击主页上的MyhawaiSpastore链接,访问者将被发送到shop.php,其中所有属于MyhawaiSpa的项目都将显示出来。点击MyHawaiiSpastore上的任何产品,就会打开product.php页面,其中提到了产品的详细信息 目前,我在PHP中使用查询字符串管理它。因此,每个商店的区别如下: myweb

让我举例说明:

每当有人在我的网站上开户时,他/她也会创建一个店铺ID,如
MyHawaiiSpa
。一旦生成存储ID,则无法更改它。在此,我假设此帐户的
pkid
为1

现在,访问者点击主页上的
MyhawaiSpa
store链接,访问者将被发送到
shop.php
,其中所有属于
MyhawaiSpa
的项目都将显示出来。点击
MyHawaiiSpa
store上的任何产品,就会打开
product.php
页面,其中提到了产品的详细信息

目前,我在PHP中使用查询字符串管理它。因此,每个商店的区别如下:

mywebsite.com/user/shop.php?sid=1

依靠网络学习,我试着做了以下事情,但不起作用

我想得到我在这里提到的结果:

www.mywebsite.com/user/shop.php?mid=1&sid="MyHawaiiSpa" 

这就是我到目前为止所做的:

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Product Details 1" enabled="true" stopProcessing="true">
                    <match url="^user/(.+)$" />
                    <action type="Rewrite" url="user/shop.php?sid={R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>


使用.htaccess。它可以用于重写URL。

问题不在于如果您使用的是
IIS
或任何
OS
,您的请求可以通过
htaccess
mod\u rewrite

1-通过在测试页面中添加
phpinfo()
,检查您的php信息是否启用了mod_重写扩展

2-创建文件
.htaccess
,并将此文件放入脚本根目录中

3-将此规则添加到
.htaccess
文件中

RewriteEngine On
RewriteBase /

RewriteRule ^user/(.*)$  shop.php?sid=$1 [L,NC,QSA]
RewriteRule ^user/(.*)/(.*)$ user/shop.php?mid=$2&sid=$1   [L,NC,QSA]
现在你可以使用这个链接了

www.mywebsite.com/user/MyHawaiiSpa

添加此规则只是为了确保您是否做得很好

1-创建test.php页面并将其添加到根文件夹中

将此行添加到下面的
.htaccess
文件
RewriteBase/

RewriteRule ^test test.php [L,NC]
现在进入页面

www.mywebsite.com/test

如果仍然无法工作,您需要在php中启用并安装mod_rewrite,您可以在google上搜索它。下面是我现在可以工作的最终代码

<configuration>
    <system.webServer>
        <rewrite>  
            <rules>  
                <rule name="QueryStringDynamicRewrite" stopProcessing="true">  
                    <match url="^(.*)$" ignoreCase="false" />  
                        <conditions>  
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />  
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                            <add input="{REQUEST_URI}" pattern="^/(admin|mdm|user/includes)" ignoreCase="false" negate="true" />
                        </conditions>  
                        <action type="Rewrite" url="user/shop.php?sid={R:1}" appendQueryString="true" />  
                </rule>
            </rules>  
        </rewrite> 
    </system.webServer>
</configuration>

IIS7或以上Web服务器、Web.Config、PHP、MySQL组合的重要内容

  • 以前我使用了“^user/(.+)$”,现在我已将其替换为“^user/(.*)”(+符号替换为*)

  • 我向我的网络托管服务器提供商GoDaddy确认,他们说我们应该在IIS中使用web.Config


您是否尝试使用
mod_rewrite
重定向链接?但我正在Windows 7中使用IIS。没有,在phpinfo()测试页中没有mod_rewrite扩展。我只找到了此变量-SERVER[“IIS_urrewritemodule”]它的值是7.1.0761.0Hello,它给出了这个错误。找不到。请求的文档在此服务器上找不到。我将.htaccess放在用户文件夹和根文件夹下进行检查,但在这两种情况下,它都不工作。www.mywebsite.com/test,它没有给出错误,但要求输入用户名/密码。请让我知道。我想我正在尝试访问网站的根目录,这就是为什么它需要用户名/密码
RewriteRule ^test test.php [L,NC]
www.mywebsite.com/test
<configuration>
    <system.webServer>
        <rewrite>  
            <rules>  
                <rule name="QueryStringDynamicRewrite" stopProcessing="true">  
                    <match url="^(.*)$" ignoreCase="false" />  
                        <conditions>  
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />  
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                            <add input="{REQUEST_URI}" pattern="^/(admin|mdm|user/includes)" ignoreCase="false" negate="true" />
                        </conditions>  
                        <action type="Rewrite" url="user/shop.php?sid={R:1}" appendQueryString="true" />  
                </rule>
            </rules>  
        </rewrite> 
    </system.webServer>
</configuration>