簡體   English   中英

從CI和Wordpress中刪除index.php

[英]Remove index.php from CI and Wordpress

我在根文件夾上有CI,在子目錄上有Wordpress。

經過幾天的努力,我發現問題是:-在WP web.config之前讀取CI Web配置,因此成功刪除了CI index.php,但未刪除WP。

訪問網站CI調用CI web.config,已處理。
訪問網站CI.com/blog並調用CI web.config,已處理。

如果URL不包含Blog,則只需添加一個index.php
如果URL包含blog,則在網站后添加index.php,然后在博客后添加另一個index.php

題:
如何做匹配網址“如果URL有博客,然后添加另一個index.php”? 如果我錯了,請糾正我。

在確定CI目錄上正確的webconfig的任何幫助將不勝感激!

original URL:

CI

  website.com/index.php/en/user/

WP

  website.com/index.php/blog/index.php/ 



website.com/en/user => codeigniter with the controller User
website.com/blog/hello-world => error 404
website.com/blog/index.php/hello-world => Good result

/apps
/system
/blog
   ../web.config WP =>remove WP index.php
   ../index.php

/web.config CI =>remove CI index.php
/index.php

Web配置刪除CI index.php

 <?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.webServer>   
   <rewrite>
    <rules>
        <rule name="RuleRemoveIndex" stopProcessing="true">
            <match url="^(.*)$" ignoreCase="false" />
            <conditions>
                <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}" appendQueryString="true"/>
        </rule>

    </rules>
    </rewrite>

    </system.webServer>
 </configuration>

/ blog => WP應用

WP目錄上的web.config刪除WP index.php

   <?xml version="1.0" encoding="UTF-8"?>
  <configuration>
    <system.webServer>
    <rewrite>
        <rules>
            <rule name="WordPress Rule 1" stopProcessing="true">
                <match url="^index\.php$" ignoreCase="false" />
                <action type="None" />
            </rule>
            <rule name="WordPress Rule 2" stopProcessing="true">
                <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
                <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
            </rule>
            <rule name="WordPress Rule 3" stopProcessing="true">
                <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
                <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
            </rule>
            <rule name="WordPress Rule 4" stopProcessing="true">
                <match url="^" ignoreCase="false" />
                <conditions logicalGrouping="MatchAny">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
                </conditions>
                <action type="None" />
            </rule>
            <rule name="WordPress Rule 5" stopProcessing="true">
                <match url="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" />
                <action type="Rewrite" url="{R:2}" />
            </rule>
            <rule name="WordPress Rule 6" stopProcessing="true">
                <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
                <action type="Rewrite" url="{R:2}" />
            </rule>
            <rule name="WordPress Rule 7" stopProcessing="true">
                <match url="." ignoreCase="false" />
                <action type="Rewrite" url="index.php" />
            </rule>
        </rules>
    </rewrite>
     </system.webServer>
   </configuration>

更新:如果存在blog / url,則在根目錄上進行Web配置,重寫index.php。我發現是否刪除了CI上的Web配置規則,但這不會影響WP。 它將website.com/blog/hello-world well加載website.com/blog/hello-world well

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>

                <rule name="wordpress1" patternSyntax="Wildcard">
            <match url="blog[/]?$"/>
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
                </conditions>
            <action type="Rewrite" url="index.php/{R:1}"/>
        </rule>
        <rule name="RuleRemoveIndex" stopProcessing="true">
            <match url="^(.*)$" ignoreCase="false" />
            <conditions>
                <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}" appendQueryString="true"/>
        </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

結果:404錯誤

解決方案是在每個目錄中使用web.config。 當我刪除CI web.config上的規則時,發現可以很好地加載WP。

我在CI web.config上使用它

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.webServer>   
   <rewrite>
    <rules>
        <rule name="RuleRemoveIndex" stopProcessing="true">
            <match url="^(.*)$" ignoreCase="false" />
            <conditions>
                <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}" appendQueryString="true"/>
        </rule>

    </rules>
    </rewrite>

    </system.webServer>
 </configuration>

在WP web.config上

   <?xml version="1.0" encoding="UTF-8"?>
  <configuration>
    <system.webServer>
    <rewrite>
        <rules>
        <clear/> => add clear to clear the predefined connection strings
            <rule name="WordPress Rule 1" stopProcessing="true">
                <match url="^index\.php$" ignoreCase="false" />
                <action type="None" />
            </rule>
            <rule name="WordPress Rule 2" stopProcessing="true">
                <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
                <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
            </rule>
            <rule name="WordPress Rule 3" stopProcessing="true">
                <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
                <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
            </rule>
            <rule name="WordPress Rule 4" stopProcessing="true">
                <match url="^" ignoreCase="false" />
                <conditions logicalGrouping="MatchAny">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
                </conditions>
                <action type="None" />
            </rule>
            <rule name="WordPress Rule 5" stopProcessing="true">
                <match url="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" />
                <action type="Rewrite" url="{R:2}" />
            </rule>
            <rule name="WordPress Rule 6" stopProcessing="true">
                <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
                <action type="Rewrite" url="{R:2}" />
            </rule>
            <rule name="WordPress Rule 7" stopProcessing="true">
                <match url="." ignoreCase="false" />
                <action type="Rewrite" url="index.php" />
            </rule>
        </rules>
    </rewrite>
     </system.webServer>
   </configuration>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM