2

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

<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。这也可能是主机的问题,但我想先用尽我的选择。

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

4

1 回答 1

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]
于 2013-04-06T12:40:15.010 回答