1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 在phpstudy8上新配置的ThinkPHP5项目 因apache服务没有打开重写 伪静态 报错的解决方案

在phpstudy8上新配置的ThinkPHP5项目 因apache服务没有打开重写 伪静态 报错的解决方案

时间:2022-04-16 09:17:45

相关推荐

在phpstudy8上新配置的ThinkPHP5项目 因apache服务没有打开重写 伪静态 报错的解决方案

在phpstudy8上新配置的ThinkPHP5项目,因apache服务没有打开重写、伪静态,首页可以正常打开,当点击跳转链接时,比如后台登录等页面就提示报错:

Not Found

The requested URL /index/xxx/xxxwas not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

解决步骤:

1.这个错误一般是要配置伪静态,Apache服务器

如果没有开启了Apache的rewrite_module模块:

找到apache的httpd.conf文件,放开这个模块让我来

LoadModule rewrite_module modules/mod_rewrite.so

就是将前面"#"去掉,如果不存在则添加上句。

2.配置虚拟主机

如果你的网站是根目录的话:找到apache目录,conf/vhosts目录下对应的虚拟主机文件。

<Directory />

Options FollowSymLinks

AllowOverride None

</Directory>

将上面的None改为All

如果你的站点不在根目录,设置如下:

<Directory ".../.../.../.../directory_name">

Order allow,deny

Allow from all

AllowOverride All

</Directory>

3.在项目根目录创建文件.htaccess文件,写入以下代码

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>

4.重启服务器,重新访问网站。

也可以直接先做第3步,如果不行再把第1、2步也做了。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。