我已经试了好几个小时了!
我的codeigniter应用程序位于webroot的子文件夹中,子文件夹名为“Tat”。
我正在使用codeigniter文件夹(应用程序和系统文件夹旁边)中的以下.htaccess文件:

<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>

如果我访问:
127.0.0.1/Tat/-我去了CodeIgniter应用程序,很好。
如果我访问:
127.0.0.1/Tat/index.php/register-我转到我的CI应用程序的register页面(不希望index.php在那里!)
如果我访问:
127.0.0.1/Tat/register-它把我带到整个服务器的web根目录!我要这个带我去登记处!
我不知道怎么做!
值得一提的是:
*我的基本URL设置为:$config['base_URL']='http://127.0.0.1:5678/Tat';
*我的索引页已设置:$config['index_page']='';
*我完全控制服务器,它是一个在Ubuntu Precise 64上运行Apache2的开发服务器。
如果有人能给我指出正确的方向,或者纠正我的.htaccess,或者告诉我如何修改apache设置,那就太棒了!
谢谢。

最佳答案

您的站点位于子文件夹中,因此请在第4行中设置“重写基”,如下所示:

RewriteBase /Tat

07-27 23:51