项目场景:
thinphp项目转移到其他其他电脑上,直接压缩原项目,到新电脑上解压
问题描述
thinkphp项目转移到其他电脑上网站打不开
例如:打开网站提示
Not Found
The requested URL /captcha was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Not Found
The requested URL /captcha was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
原因分析:
网站首页能够打开只有路由定义的其他网站打不开
解决方案:
将以下代码复制到如下文件内
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
#从写条件
RewriteCond %{HTTP:Authorization} ^(.+)$
#从写规则
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>`
这该行代码作用于Apache,让apcha理解路由规则
这是修改后成功示例