如何将 myforum.com/index.php 永久重定向到 myforum.com

发布于 2025-01-05 09:49:41 字数 2980 浏览 0 评论 0原文

我在 IIS 7.5 上的 Windows Server 2008 上使用 MYBB php 论坛

我想将 index.php 永久重定向到主 url

我该怎么做?

示例

http://forum.monstermmorpg.com/index.php

将被重定向到

http://forum.monstermmorpg.com

我该怎么做?谢谢。

我正在使用的重写规则

    <?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^([^&amp;]*)&amp;(.*)$" ignoreCase="false" />
                    <action type="Redirect" url="http://forum.monstermmorpg.com/{R:1}?{R:2}" appendQueryString="true" redirectType="Permanent" />
                </rule>
                <rule name="Imported Rule 2" stopProcessing="true">
                    <match url="^sitemap\-([^./]+)\.xml$" />
                    <action type="Rewrite" url="misc.php?google_seo_sitemap={R:1}" appendQueryString="true" />
                </rule>
                <rule name="Imported Rule 3" stopProcessing="true">
                    <match url="^Forum\-([^./]+)$" />
                    <action type="Rewrite" url="forumdisplay.php?google_seo_forum={R:1}" appendQueryString="true" />
                </rule>
                <rule name="Imported Rule 4" stopProcessing="true">
                    <match url="^Thread\-([^./]+)$" />
                    <action type="Rewrite" url="showthread.php?google_seo_thread={R:1}" appendQueryString="true" />
                </rule>
                <rule name="Imported Rule 5" stopProcessing="true">
                    <match url="^Announcement\-([^./]+)$" />
                    <action type="Rewrite" url="announcements.php?google_seo_announcement={R:1}" appendQueryString="true" />
                </rule>
                <rule name="Imported Rule 6" stopProcessing="true">
                    <match url="^User\-([^./]+)$" />
                    <action type="Rewrite" url="member.php?action=profile&amp;google_seo_user={R:1}" appendQueryString="true" />
                </rule>
                <rule name="Imported Rule 7" stopProcessing="true">
                    <match url="^Calendar\-([^./]+)$" />
                    <action type="Rewrite" url="calendar.php?google_seo_calendar={R:1}" appendQueryString="true" />
                </rule>
                <rule name="Imported Rule 8" stopProcessing="true">
                    <match url="^Event\-([^./]+)$" />
                    <action type="Rewrite" url="calendar.php?action=event&amp;google_seo_event={R:1}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

I am using MYBB php forum at windows server 2008 on IIS 7.5

I want to permanently redirect index.php to main url

How can i do that ?

Example

http://forum.monstermmorpg.com/index.php

Will be redirected to

http://forum.monstermmorpg.com

How can i do that ? Thank you.

The rewrite rules i am using

    <?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1" stopProcessing="true">
                    <match url="^([^&]*)&(.*)$" ignoreCase="false" />
                    <action type="Redirect" url="http://forum.monstermmorpg.com/{R:1}?{R:2}" appendQueryString="true" redirectType="Permanent" />
                </rule>
                <rule name="Imported Rule 2" stopProcessing="true">
                    <match url="^sitemap\-([^./]+)\.xml$" />
                    <action type="Rewrite" url="misc.php?google_seo_sitemap={R:1}" appendQueryString="true" />
                </rule>
                <rule name="Imported Rule 3" stopProcessing="true">
                    <match url="^Forum\-([^./]+)$" />
                    <action type="Rewrite" url="forumdisplay.php?google_seo_forum={R:1}" appendQueryString="true" />
                </rule>
                <rule name="Imported Rule 4" stopProcessing="true">
                    <match url="^Thread\-([^./]+)$" />
                    <action type="Rewrite" url="showthread.php?google_seo_thread={R:1}" appendQueryString="true" />
                </rule>
                <rule name="Imported Rule 5" stopProcessing="true">
                    <match url="^Announcement\-([^./]+)$" />
                    <action type="Rewrite" url="announcements.php?google_seo_announcement={R:1}" appendQueryString="true" />
                </rule>
                <rule name="Imported Rule 6" stopProcessing="true">
                    <match url="^User\-([^./]+)$" />
                    <action type="Rewrite" url="member.php?action=profile&google_seo_user={R:1}" appendQueryString="true" />
                </rule>
                <rule name="Imported Rule 7" stopProcessing="true">
                    <match url="^Calendar\-([^./]+)$" />
                    <action type="Rewrite" url="calendar.php?google_seo_calendar={R:1}" appendQueryString="true" />
                </rule>
                <rule name="Imported Rule 8" stopProcessing="true">
                    <match url="^Event\-([^./]+)$" />
                    <action type="Rewrite" url="calendar.php?action=event&google_seo_event={R:1}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挥剑断情 2025-01-12 09:49:41

如果您使用 web.config 文件并安装了 IIS 重写模块,则此规则应该有效

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
     <modules runAllManagedModulesForAllRequests="true" />
        <rewrite>
            <rules>
                <rule name="CanonicalHostNameRule" stopProcessing="true">
                  <match url="^(\w*/)?index\.php" />
            <conditions>
            <add input="{HTTP_HOST}" pattern="forum\.monstermmorpg\.com$" />
            </conditions>
                   <action type="Redirect" url="http://forum.monstermmorpg.com/{R:1}" />
                </rule>
            </rules>
        </rewrite>
  </system.webServer>
</configuration>

If your using a web.config file and have the IIS Rewrite Module installed, this rule should work

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
     <modules runAllManagedModulesForAllRequests="true" />
        <rewrite>
            <rules>
                <rule name="CanonicalHostNameRule" stopProcessing="true">
                  <match url="^(\w*/)?index\.php" />
            <conditions>
            <add input="{HTTP_HOST}" pattern="forum\.monstermmorpg\.com$" />
            </conditions>
                   <action type="Redirect" url="http://forum.monstermmorpg.com/{R:1}" />
                </rule>
            </rules>
        </rewrite>
  </system.webServer>
</configuration>
南…巷孤猫 2025-01-12 09:49:41

在index.php上写下这样的内容:

//> header 302
if ($_SERVER['REQUEST_URI']=='/index.php')
 header('Location: /');

//> header 301
header( 'HTTP/1.1 301 Moved Permanently' );
header( 'Location: /' );

On index.php write something like this:

//> header 302
if ($_SERVER['REQUEST_URI']=='/index.php')
 header('Location: /');

//> header 301
header( 'HTTP/1.1 301 Moved Permanently' );
header( 'Location: /' );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文