在 codeigniter 中找不到请求
request not found in codeigniter
我正在使用 codeigniter 开发 Web 应用程序。
我有问题
当我这样请求控制器时
http://localhost:8080/Saffron/Product/137/test-text
一切正常,但是当我这样请求控制器时
http://localhost:8080/Saffron/Product/137/مهارت-های-آموزشی-در مطالعه
收到这个错误
The requested URL /Saffron/Product/137/کتاب-غلبه-بر-اضطراب-در-Ù…ØÛŒØ·-های-آموزشی was not found on this server.
我使用这个 htaccess 规则
Options -Indexes -MultiViews +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /Saffron/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php? [L]
</IfModule>
它在服务器上运行没有错误 我在 wamp 上有这个问题 locahost.where 是问题吗?
更新:
我终于找到了:
重写引擎开启
RewriteBase /藏红花/
重写规则 ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
重写规则。 /Saffron/index.php [L]
工作正常
转到您的配置
替换 $config['base_url'] = '';在下面的代码中,它将如何帮助您
if( (php_sapi_name() == 'cli') or defined('STDIN') )
{
$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://". (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '127.0.0.1');
}
else
{
$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://". (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '127.0.0.1');
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
}
$config['secure_base_url'] = ((isset($_SERVER['SERVER_NAME'])) ? "https://".$_SERVER['SERVER_NAME'] : '');
$config['secure_base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
对于 htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /folder name of your webapp/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/ [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/ [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 index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/ [L]
</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.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
您可以将类似的内容添加到您的路由器文件 application/config/routes.php
。
$route['Product/(:num)/(:any)] = 'Product//';
我假设 Saffron 是您的 base_url
目录。
查看下方了解更多信息:
我正在使用 codeigniter 开发 Web 应用程序。
我有问题
当我这样请求控制器时
http://localhost:8080/Saffron/Product/137/test-text
一切正常,但是当我这样请求控制器时
http://localhost:8080/Saffron/Product/137/مهارت-های-آموزشی-در مطالعه
收到这个错误
The requested URL /Saffron/Product/137/کتاب-غلبه-بر-اضطراب-در-Ù…ØÛŒØ·-های-آموزشی was not found on this server.
我使用这个 htaccess 规则
Options -Indexes -MultiViews +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /Saffron/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php? [L]
</IfModule>
它在服务器上运行没有错误 我在 wamp 上有这个问题 locahost.where 是问题吗?
更新:
我终于找到了:
重写引擎开启
RewriteBase /藏红花/
重写规则 ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
重写规则。 /Saffron/index.php [L]
工作正常
转到您的配置 替换 $config['base_url'] = '';在下面的代码中,它将如何帮助您
if( (php_sapi_name() == 'cli') or defined('STDIN') )
{
$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://". (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '127.0.0.1');
}
else
{
$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://". (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '127.0.0.1');
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
}
$config['secure_base_url'] = ((isset($_SERVER['SERVER_NAME'])) ? "https://".$_SERVER['SERVER_NAME'] : '');
$config['secure_base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
对于 htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /folder name of your webapp/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/ [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/ [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 index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/ [L]
</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.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
您可以将类似的内容添加到您的路由器文件 application/config/routes.php
。
$route['Product/(:num)/(:any)] = 'Product//';
我假设 Saffron 是您的 base_url
目录。
查看下方了解更多信息: