在godaddy中的Codeigniter .htaccess
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在godaddy中的Codeigniter .htaccess相关的知识,希望对你有一定的参考价值。
我现在正在努力工作几个小时:我在godaddy托管的子文件夹中有一个codeigniter应用程序,让我们说:
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>
我读了这篇文章:https://github.com/bcit-ci/CodeIgniter/wiki/Godaddy-Installation-Tips,但它也没有帮助。也许是因为我的ci应用程序在子文件夹中?
如何隐藏index.php?并使它与友好的网址一起工作?
答案
你的/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/application/config/config.php
你需要有这个配置:
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
另一答案
使用以下.htaccess为Godaddy托管服务器。如果有效,请告诉我们。
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1
另一答案
在你的根目录(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>
然后是你的application / config / config.php:
$config['index_page'] = '';
这应该可以解决问题。
希望这可以帮助!
另一答案
我很惊讶没有人写过你应该放的东西
Options +FollowSymlinks
在.htaccess文件的开头,GoDaddy托管网站。
以上是关于在godaddy中的Codeigniter .htaccess的主要内容,如果未能解决你的问题,请参考以下文章
子目录中的 CodeIgniter 站点,htaccess 文件可能会干扰主目录中的 htaccess 文件?