中从Codeigniter中删除index.php Codeigniter应用程序通常使用mod_rewrite从url中排除字符串index.php
。我在同一个域中有两个Codeigniter应用程序。一个Codigniter应用程序位于Web根文件夹中,另一个Codigniter应用程序位于Web根文件夹的子文件夹中。mod_rewrite在子目录
笨应用1:
http://domain.com/index.php
笨应用2(着陆页的应用程序):
http://domain.com/land/index.php
两个笨的应用是每个原子,不把它们之间共享任何文件。 Codeigniter框架中的每个文件都在public_html/
中,并且再次在public_html/land/
中。所以我需要在网址/
的文件夹中排除字符串index.php
,并排除/land/
子文件夹中的字符串index.php
。
根文件夹中的.htaccess文件使用Codeigniter wiki中广泛推荐的mod_rewrite规则(代码如下),这组规则适用于根Codeigniter应用程序(应用程序1)。这些规则驻留在Web根文件夹中。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 /index.php
</IfModule>
上述一套规则在根Codeigniter应用程序中从urls中删除index.php
没有问题。但是这组规则似乎不允许执行public_html/land/.htaccess
中的mod_rewrite规则。
当我删除public_html/.htaccess
中的mod_rewrite规则时,开始评估public_html/land/.htaccess
中的mod_rewrite规则。
有没有办法改变public_html/.htaccess
中的mod_rewrite规则来处理打算访问/land/
子文件夹的URL的特殊情况?
我认为最好的解决方案可能是更改public_html/.htaccess
中的mod_rewrite规则,以允许在url中寻址子文件夹时执行public_html/land/.htaccess
中的mod_rewrite规则。我愿意接受任何建议。
对“为什么不只是使用子域?”这个问题的先发制人的答案。 1.节省SSL证书的费用。 2)非技术用户有时会被子域名混淆用于营销基本域名。
对“为什么不将Codeigniter应用程序结合使用以在框架中使用相同的文件?”的先发性回答?复制框架文件是保持版本存储库分离的简单方法。
将该文件夹添加到RewriteBase中,如下所示:RewriteBase/land/ – Drewdin