The requested URL was not found on this server

时间秒杀一切 提交于 2021-01-21 05:51:31

问题


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.

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.

How to sort this out? I am a beginner.


回答1:


Add these lines to .htaccess: (based on codeigniter urls docs)

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



回答2:


i will help to you .. i have faced this problem few days ago .. try to include below code in your .htaccess file.

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]
ErrorDocument 404 index.php



回答3:


Do you have a Site.php Controller in your /application/controllers folder?

Or, do you have a route that points to an existing Controller/function?

Follow either of the following two methods:

  1. Create a Controller, and name is /application/controller/Site.php. You can copy the Welcome.php Controller for quick file creation. Then change the name of the Class to Site instead of Welcome. Now, add a function in there and name it public function ourservices()

-or-

  1. 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 called public function ourservices() in your /application/controllers/Welcome.php controller.

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.




回答4:


Add these lines in your .htaccess (your project root directory):

RewriteEngine On
RewriteBase /yoursite

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

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



回答5:


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




回答6:


Open "000-default.config" in editor, file available in "/etc/apache2/sites-available/000-default.conf" and change "AllowOverride" from "None" to "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

  1. sudo a2enmod rewrite
  2. sudo service apache2 restart

then check your page.




回答7:


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



来源:https://stackoverflow.com/questions/44162752/the-requested-url-was-not-found-on-this-server

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