【问题标题】:Server 500 error - moved app in subfolder服务器 500 错误 - 在子文件夹中移动应用程序
【发布时间】:2013-03-28 20:28:49
【问题描述】:

我在我网站的子文件夹中开发了一个应用程序,它运行良好。

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|swf|uploads|js|css|robots\.txt)
RewriteRule ^(.*)$ /app/index.php/$1 [L]
</IfModule>

此文件运行良好,因此无需在应用程序中导航 index.php。现在我将应用程序移动到网站的根目录并将最后一行更改为

RewriteRule ^(.*)$ index.php/$1 [L]

现在我开始收到内部服务器错误 500。我不确定这是我所做的,还是需要以不同方式配置 .htacces。这也可能是主机的问题,但我想先用尽我的选择。

任何帮助将不胜感激。提前致谢。

【问题讨论】:

    标签: php apache .htaccess codeigniter mod-rewrite


    【解决方案1】:

    如果您在托管根目录中,您只需要

     <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond $1 !^(index\.php|images|swf|uploads|js|css|robots\.txt)
        RewriteRule ^(.*)$ /index.php/$1 [L]
        </IfModule>
    

    如果您的站点位于文件夹 /foo 您需要:

    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteBase /foo
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond $1 !^(index\.php|images|swf|uploads|js|css|robots\.txt)
        RewriteRule ^(.*)$ /foo/index.php/$1 [L]
        </IfModule>
    

    如果仍然不工作,试试这个,对我来说它完全有效:

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

    【讨论】:

    • 谢谢你,你是一个救生员。我总是被 .htaccess 文件卡住。我认为是时候学习内部结构了。
    • @AmanAujla 哈哈,我希望有一天我可以挽救一些生命,无论如何,一旦你了解了它的工作原理,这些都是简单的开始问题;)
    猜你喜欢
    • 2016-08-14
    • 1970-01-01
    • 2019-06-12
    • 2015-11-07
    • 2015-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多