Wordpress + Xenforo rewrite rules on IIS 7.5

Thảo luận trong 'SEO for XenForo' bắt đầu bởi VXF, 12/5/12.

1votes
5/5, 1 vote

  1. VXF

    VXF Be like no other .. Staff Member

    Bài viết:
    1,277
    Likes :
    2,175
    Giả sử bạn cài đặt XenForo trong thư mục tên là community và là thư mục nằm bên trong thư mục Wordpress. Đường dẫn đến Wordpress và XenForo lần lượt là: www.domain.com (Wordpress) ; www.domain.com/community (Xenforo)

    Để làm được điều này chúng ta cần 2 file web.config. File đầu tiên đặt trong thư mục gốc của Wordpress và file thư 2 nằm trong thư mục gốc của XenForo.

    Dưới đây là code file web.config của Wordpress.
    Mã:
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
     
        <defaultDocument>
          <files>
            <clear />
            <add value="index.php" />
          </files>
        </defaultDocument>
        <rewrite>
          <rules>
            <rule name="CanonicalHostNameRule1">
              <match url="(.*)" />
              <conditions>
                <add input="{HTTP_HOST}" pattern="^www\.domain\.com$" negate="true" />
              </conditions>
              <action type="Redirect" url="http://www.domain.com/{R:1}" />
            </rule>
            <rule name="WordPress Rule" stopProcessing="true">
              <match url="^(.*)$" ignoreCase="false" />
              <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
              </conditions>
              <action type="Rewrite" url="index.php/{R:1}" />
            </rule>
          </rules>
          <outboundRules>
            <preConditions>
              <preCondition name="ResponseIsHtml1">
                <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
              </preCondition>
            </preConditions>
          </outboundRules>
        </rewrite>
      </system.webServer>
      <system.net>
        <mailSettings>
          <smtp from="support@domain.com">
            <network host="localhost" />
          </smtp>
        </mailSettings>
      </system.net>
    </configuration>
    Lưu ý:
    - Mình có thêm canonical rule để redirect domain.com to www.domain.com. Nếu bạn không muốn điều này có thể gỡ bỏ.
    - Thiết lập email support@domain.com sử dụng SMTP server cho phù hợp.

    Dưới đây là file web.config của XenForo. (Hãy đặt nó vào thư mục gốc của XenForo)
    Mã:
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <rewrite>
          <rules>
            <clear />
            <rule name="CanonicalHostNameRule1">
              <match url="(.*)" />
              <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTP_HOST}" pattern="^www\.domain\.com$" negate="true" />
              </conditions>
              <action type="Redirect" url="http://www.domain.com/{R:1}" />
            </rule>
            <rule name="XenForo Rule 1" stopProcessing="true">
              <match url="^.*$" />
              <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
              </conditions>
              <action type="None" />
            </rule>
            <rule name="XenForo Rule 2" stopProcessing="true">
              <match url="^(data|js|styles|install)" />
              <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
              <action type="None" />
            </rule>
            <rule name="Xenforo Rule 3" stopProcessing="true">
              <match url="^.*$" />
              <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
              <action type="Rewrite" url="index.php" />
            </rule>
            <rule name="Xenforo Rule 4" stopProcessing="true">
              <match url="^(.*)$" ignoreCase="false" />
              <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
              </conditions>
              <action type="Rewrite" url="index.php/{R:1}" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>
    Lưu ý: Hãy chắc chắn là Module URL rewrite đã được cài đặt nhé.
     
    Đang tải...
  2. banhmikho

    banhmikho New Member

    Bài viết:
    6
    Likes :
    0
    giải thích thêm đc ko, e ko hiểu lắm dùng để làm gì ^^:)
     
  3. Coolboyhn

    Coolboyhn Member

    Bài viết:
    503
    Likes :
    138
    hướng dẫn mình với htaccess được không bạn? Thanks
     
  4. bromboy2010

    bromboy2010 Member

    Bài viết:
    246
    Likes :
    37
    Cho mình hỏi là mình add cái web.config của xenforo vào xong nó chỉ chạy www.---.com chứ k fải ---.com như bình thường mình chạy :( h mình phải làm sao cho nó thành ---.com vậy mọi người.
     
comments powered by Disqus

Chia sẻ trang này

Đang tải...