[英]Remove index.php from CI and Wordpress
I got CI on root folder and Wordpress on sub directory. 我在根文件夹上有CI,在子目录上有Wordpress。
After struggling for days I found The issue is: - CI web config is read before WP web.config so CI index.php is successfully removed but NOT WP's. 经过几天的努力,我发现问题是:-在WP web.config之前读取CI Web配置,因此成功删除了CI index.php,但未删除WP。
Accessing website.com calling CI web.config,processed. 访问网站CI调用CI web.config,已处理。
Accessing website.com/blog calling CI web.config,processed. 访问网站CI.com/blog并调用CI web.config,已处理。
If URL contains no blog , just add an index.php 如果URL不包含Blog,则只需添加一个index.php
If URL contains blog , add an index.php after website then add another index.php after blog 如果URL包含blog,则在网站后添加index.php,然后在博客后添加另一个index.php
Question: 题:
How to do the match URL "IF URL has blog then add another index.php"? 如何做匹配网址“如果URL有博客,然后添加另一个index.php”? Please correct me if I am wrong. 如果我错了,请纠正我。
Any help on determining the right webconfig on CI directory would be greatly appreciated! 在确定CI目录上正确的webconfig的任何帮助将不胜感激!
original URL:
CI CI
website.com/index.php/en/user/
WP 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 config to remove CI 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 app / blog => WP应用
web.config on WP dir to remove WP index.php 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>
UPDATE: web config on root directory if there is blog/ url, rewrite index.php I found out if I deleted web config rules on CI , it doesnot affect WP. 更新:如果存在blog / url,则在根目录上进行Web配置,重写index.php。我发现是否删除了CI上的Web配置规则,但这不会影响WP。 it would load website.com/blog/hello-world well
它将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>
result: 404 error 结果:404错误
The solution is using web.config in each directory. 解决方案是在每个目录中使用web.config。 When I erased the rules on CI web.config , I found out I can load the WP well. 当我删除CI web.config上的规则时,发现可以很好地加载WP。
I use this on CI web.config 我在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>
on WP web.config 在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.