Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Codeigniter 4路由在实时服务器上不工作_Php_.htaccess_Codeigniter - Fatal编程技术网

Php Codeigniter 4路由在实时服务器上不工作

Php Codeigniter 4路由在实时服务器上不工作,php,.htaccess,codeigniter,Php,.htaccess,Codeigniter,请帮助..我正在开发一个网站。它在本地运行正常。但当我将其上载到godaddy上的windows server时,只有默认控制器工作。获取错误 “没有找到 在此服务器上找不到请求的文档。“ 文档根为httpdocs/public。 这是公共频道的htaccess # Disable directory browsing Options All -Indexes # -----------------------------------------------------------------

请帮助..我正在开发一个网站。它在本地运行正常。但当我将其上载到godaddy上的windows server时,只有默认控制器工作。获取错误 “没有找到 在此服务器上找不到请求的文档。“ 文档根为httpdocs/public。 这是公共频道的htaccess

# Disable directory browsing
Options All -Indexes

# ----------------------------------------------------------------------
# Rewrite engine
# ----------------------------------------------------------------------

# Turning on the rewrite engine is necessary for the following rules and features.
# FollowSymLinks must be enabled for this to work.
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On

# If you installed CodeIgniter in a subfolder, you will need to
# change the following line to match the subfolder you need.
# http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
# RewriteBase /

# Redirect Trailing Slashes...
RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]
    

# Rewrite "www.example.com -> example.com"
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to the front controller, index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
  

# Ensure Authorization header is passed along
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

<IfModule !mod_rewrite.c>
   # If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 index.php
</IfModule>

# Disable server signature start
ServerSignature Off
# Disable server signature end

当您单击指向另一个控制器函数的链接时,您的URL是什么样子的?它里面有index.php吗?当我输入index.php到url时,它可以工作,当我删除它时,会出现错误“未找到请求的文档未在此服务器上找到”。然后是服务器问题。由于它是windows服务器,我不知道如何在服务器端解决它。但是在codeigniter中,您可以在所有URL中使用index.php,这样您至少可以有一个工作站点。删除.htaccess并在应用程序配置中将其设置为在url中包含index.php。
<IfModule mod_rewrite.c>
DirectoryIndex /public/index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|assets|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./public/index.php/$1 [L,QSA]
</IfModule>
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);
$routes->match(['get', 'post'], '/Login', 'Home::login');