繁体   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