Server 500 error - moved app in subfolder

浪子不回头ぞ 提交于 2019-12-13 16:22:28

问题


I developed an application in a subfolder of my website and it worked fine.

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

This file was working fine so and index.php was not required to navigate within the application. Now I moved the application to root of website and changes the last line to

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

Now I have start getting Internal Server Error 500. I am not sure that it is something I have done or the .htacces is required to be configured differently. It might be an issue with host too, but I want to exhaust my options first.

Any help will be appreciated. Thanks in advance.


回答1:


if you in root of hosting you just need

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

if you site in folder /foo you need:

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

if still not working try this, for me it works all over:

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


来源:https://stackoverflow.com/questions/15850612/server-500-error-moved-app-in-subfolder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!