我正在使用codeigniter处理Web应用程序。
我有一个问题
当我请求像这样的控制器
Schema::table()
每件事都没问题,但是当我向这样的控制器请求时
http://localhost:8080/Saffron/Product/137/test-text
收到此错误
http://localhost:8080/Saffron/Product/137/مهارت-های-آموزشی-در مطالعه
我使用这个htaccess规则
The requested URL /Saffron/Product/137/کتاب-غلبه-بر-اضطراب-در-Ù…Øیط-های-آموزشی was not found on this server.
它在服务器上运行没有错误我在wamp locahost上有这个问题。这是问题吗?
我终于找到了它:
RewriteEngine On
RewriteBase / Saffron /
RewriteRule ^ index \ .php $ - [L]
RewriteCond%{REQUEST_FILENAME}! - f
RewriteCond%{REQUEST_FILENAME}!-d
重写规则。 /Saffron/index.php [L]
工作正常
答案 0 :(得分:0)
转到您的配置 替换$ 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?/$1 [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?/$1 [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?/$1 [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>
答案 1 :(得分:0)
您可以在路由器文件application/config/routes.php
中添加类似的内容。
$route['Product/(:num)/(:any)] = 'Product/$1/$2';
我假设Saffron是您的base_url
目录。
请在下面查看更多信息: