php 在此服务器上找不到请求的 URL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44162752/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The requested URL was not found on this server
提问by Rashid
While hosting a codeigniter website on my server, the first page is coming through fine and the other links are showing an error as shown below.
在我的服务器上托管 codeigniter 网站时,第一页正常显示,其他链接显示错误,如下所示。
Not Found
The requested URL /site/ourservices was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
未找到
在此服务器上找不到请求的 URL /site/ourservices。
此外,在尝试使用 ErrorDocument 处理请求时遇到 404 Not Found 错误。
How to sort this out? I am a beginner.
如何解决这个问题?我是初学者。
回答by Mohammad Hamedani
Add these lines to .htaccess: (based on codeigniter urls docs)
将这些行添加到.htaccess: (基于codeigniter urls docs)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L]
回答by Masud_ma
i will help to you .. i have faced this problem few days ago .. try to include below code in your .htaccess file.
我会帮助你..几天前我遇到了这个问题..尝试在你的.htaccess文件中包含以下代码。
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/ [L]
ErrorDocument 404 index.php
回答by Webmaster G
Do you have a Site.php
Controller in your /application/controllers
folder?
Site.php
你的/application/controllers
文件夹里有控制器吗?
Or, do you have a route that points to an existing Controller/function?
或者,您是否有指向现有控制器/功能的路由?
Follow either of the following two methods:
请遵循以下两种方法之一:
- Create a Controller, and name is
/application/controller/Site.php
. You can copy theWelcome.php
Controller for quick file creation. Then change the name of the Class toSite
instead ofWelcome
. Now, add a function in there and name itpublic function ourservices()
- 创建一个控制器,名称为
/application/controller/Site.php
. 您可以复制Welcome.php
控制器以快速创建文件。然后将类的名称更改为Site
而不是Welcome
。现在,在那里添加一个函数并命名它public function ourservices()
-or-
-或者-
- Go to your
/application/config/routes.php
file and add a route in there that checks "site/ourservices" and point it to some function in an existing controller. i.e.$route['site/ourservices'] = 'Welcome/ourservices';
, as long as you have function calledpublic function ourservices()
in your/application/controllers/Welcome.php
controller.
- 转到您的
/application/config/routes.php
文件并在其中添加一个检查“站点/我们的服务”的路由,并将其指向现有控制器中的某个功能。即$route['site/ourservices'] = 'Welcome/ourservices';
,只要您public function ourservices()
在/application/controllers/Welcome.php
控制器中调用了函数。
In the newly created function in your controller, call the appropriate view: $this->load->view('location/of/view/file')
which would try to load an existing file /application/views/location/of/view/file.php
. Make sure this file exists.
在控制器中新创建的函数中,调用适当的视图:$this->load->view('location/of/view/file')
它将尝试加载现有文件/application/views/location/of/view/file.php
。确保此文件存在。
回答by Cláudio Neto
Add these lines in your .htaccess (your project root directory):
在您的 .htaccess(您的项目根目录)中添加这些行:
RewriteEngine On
RewriteBase /yoursite
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/ [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/ [L]
回答by Zlatan
if you have uploaded your website on cpanel try , to check to check the exact error because this question is not clear 1. because you might have included site/ourservices.php in code and you forgot to upload it again or there could be something wrong with header.php
如果您已在 cpanel 上上传您的网站,请尝试检查确切的错误,因为这个问题不清楚 1. 因为您可能在代码中包含了 site/ourservices.php 并且您忘记再次上传它或者可能有问题带有 header.php
回答by Satyendra Kumar
Open "000-default.config" in editor, file available in "/etc/apache2/sites-available/000-default.conf" and change "AllowOverride" from "None" to "All":
在编辑器中打开“000-default.config”,文件在“/etc/apache2/sites-available/000-default.conf”中,并将“AllowOverride”从“None”更改为“All”:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Then save and restart your Apache server. If after doing this not opening your page then check if your Apache rewrite module is enabled or not. If not enabled then run this command in terminal
然后保存并重新启动您的 Apache 服务器。如果这样做后没有打开您的页面,请检查您的 Apache 重写模块是否已启用。如果未启用,则在终端中运行此命令
sudo a2enmod rewrite
sudo service apache2 restart
sudo a2enmod rewrite
sudo service apache2 restart
then check your page.
然后检查您的页面。