在godaddy中的Codeigniter .htaccess

问题描述 投票:2回答:4

我现在正在努力工作几个小时:我在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?并使它与友好的网址一起工作?

php .htaccess codeigniter mod-rewrite redirect
4个回答
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';

3
投票

使用以下.htaccess为Godaddy托管服务器。如果有效,请告诉我们。

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1

2
投票

在你的根目录(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'] = '';

这应该可以解决问题。

希望这可以帮助!


0
投票

我很惊讶没有人写过你应该放的东西

Options +FollowSymlinks

在.htaccess文件的开头,GoDaddy托管网站。

© www.soinside.com 2019 - 2024. All rights reserved.