【问题标题】:Showing a 404 error when navigating to another page导航到另一个页面时显示 404 错误
【发布时间】:2021-07-08 08:17:51
【问题描述】:

所以我建立了一个网站并成功将其上传到使用 Plesk 的共享主机 主页加载并且可以正常工作,但是每当我尝试导航到另一个页面时,都会出现此错误

HTTP Error 404.0 - Not Found

您要查找的资源已被删除、更改名称或暂时不可用。

我可以在我的 .htaccess 文件中添加或更改他们的任何东西

<IfModule mod_rewrite.c>

<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

##
## You may need to uncomment the following line for some hosting environments,
## if you have installed to a subdirectory, enter the name here also.
##
# RewriteBase /

##
## Uncomment following lines to force HTTPS.
##
# RewriteCond %{HTTPS} off
# RewriteRule (.*) https://%{SERVER_NAME}/$1 [L,R=301]

##
## Black listed folders
##
RewriteRule ^bootstrap/.* index.php [L,NC]
RewriteRule ^config/.* index.php [L,NC]
RewriteRule ^vendor/.* index.php [L,NC]
RewriteRule ^storage/cms/.* index.php [L,NC]
RewriteRule ^storage/logs/.* index.php [L,NC]
RewriteRule ^storage/framework/.* index.php [L,NC]
RewriteRule ^storage/temp/protected/.* index.php [L,NC]
RewriteRule ^storage/app/uploads/protected/.* index.php [L,NC]

##
## White listed folders
##
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} !/.well-known/*
RewriteCond %{REQUEST_FILENAME} !/storage/app/uploads/.*
RewriteCond %{REQUEST_FILENAME} !/storage/app/media/.*
RewriteCond %{REQUEST_FILENAME} !/storage/temp/public/.*
RewriteCond %{REQUEST_FILENAME} !/themes/.*/(assets|resources)/.*
RewriteCond %{REQUEST_FILENAME} !/plugins/.*/(assets|resources)/.*
RewriteCond %{REQUEST_FILENAME} !/modules/.*/(assets|resources)/.*
RewriteRule !^index.php index.php [L,NC]

##
## Block all PHP files, except index
##
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteRule !^index.php index.php [L,NC]

##
## Standard routes
##
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

我该如何解决这个问题

【问题讨论】:

  • 请分享更多细节。根据报错信息,你使用的不是Apache,而是IIS
  • 为了澄清@NicoHaase 的评论,htaccess 文件是 Apache Web 服务器的配置文件,而不是 IIS(它使用看起来完全不同的名为 web.config 的东西)
  • 我已经分享了@NicoHaase 向我展示的所有内容
  • 好的,然后澄清一下:您不能使用.htaccess 配置给定的网络服务器 - 要么更改网络服务器,以便您可以使用您可能在本地环境中使用的同一个 Apache,或者调整您的配置到您的主机提供的 IIS 网络服务器
  • 关于如何使用 IIS 配置@NicoHaase 的任何想法

标签: php laravel .htaccess


【解决方案1】:

所以问题是我在本地主机上使用 Apache,而我的主机使用 IIS 解决方案是使用 .htaccess

web.config 文件

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-07
    相关资源
    最近更新 更多