我已经为此挣扎了几个小时:我在godaddy主机中的子文件夹中有一个代码点火器应用程序,比如说:
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?并使其与友好的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>
然后在应用程序/config/config.php中:
$config['index_page'] = '';
这应该能解决问题。
对Godaddy托管服务器使用以下.htaccess。请告诉我们它是否有效。
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1
让你的/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';
我很惊讶没有人写你应该放
Options +FollowSymlinks
在.htaccess文件的开头,用于GoDaddy托管的网站。