Php Codeigniter.htaccess在godaddy
我为此挣扎了几个小时: 我在godaddy主机的子文件夹中有一个codeigniter应用程序,比如:Php Codeigniter.htaccess在godaddy,php,.htaccess,codeigniter,mod-rewrite,redirect,Php,.htaccess,Codeigniter,Mod Rewrite,Redirect,我为此挣扎了几个小时: 我在godaddy主机的子文件夹中有一个codeigniter应用程序,比如: mydomain.com/myfolder/myapp/ 我有这个。htaccess: <IfModule mod_rewrite.c> RewriteEngine on RewriteBase /myfolder/myapp/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST
mydomain.com/myfolder/myapp/
我有这个。htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /myfolder/myapp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]
</IfModule>
重新启动发动机
重写库/myfolder/myapp/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$/index.php?$1[L]
我读了这份文件:
但这也于事无补。可能是因为我的ci应用程序位于子文件夹中
如何隐藏index.php?并使其与友好的URL一起工作?在根目录(codeigniter的index.php所在的位置)中创建一个.htaccess文件,如下所示:
<IfModule mod_rewrite.c>
RewriteEngine On
#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
#Submitted by: Fabdrol
#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 %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
重新启动发动机
#删除用户对系统文件夹的访问权限。
#此外,这将允许您创建System.php控制器,
#以前这是不可能的。
#如果已重命名系统文件夹,则可以替换“系统”。
重写COND%{REQUEST_URI}^系统*
重写规则^(.*)$index.php?/$1[L]
#当应用程序文件夹不在系统文件夹中时
#此代码段阻止用户访问应用程序文件夹
#提交人:Fabdrol
#将“应用程序”重命名为应用程序文件夹名称。
重写cond%{REQUEST_URI}^应用程序*
重写规则^(.*)$index.php?/$1[L]
#检查用户是否试图访问有效文件,
#例如图像或css文档,如果这不是真的,它会发送
#请求index.php
#RewriteCond%{ENV:REDIRECT_STATUS}^$
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?/$1[L]
然后在应用程序/config/config.php中:
$config['index_page']=''代码>
这应该可以解决问题。让您的/myfolder/myapp/.htaccess像这样:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /myfolder/myapp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
对Godaddy托管服务器使用以下.htaccess。请让我们知道它是否有效
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1
我很惊讶没有人写信告诉你
Options +FollowSymlinks
在.htaccess文件的开头,针对GoDaddy托管的网站。我建议您在当前计划到期时尝试不同的托管,因为GoDaddy非常糟糕。来源:自己的经验很好,但这不是一个解决方案。我不能对我的客户这样说:P刚刚编辑了这个问题,如果有人能帮助我,我会得到以下错误:找不到请求的URL/mydomain/index.php在此服务器上找不到。@Perroloco删除重写基线。这个解决方案对我有效。出现“未指定输入”错误。谢谢谢谢现在它不会给我一个错误,但它总是打开欢迎控制器,即使我试图转到另一个!你知道发生了什么吗?没关系!我将uri协议更改为自动,现在它可以工作了!谢谢好的,太好了,我在回答中使用了AUTO
,以帮助任何未来的访问者了解这个问题。
Options +FollowSymlinks