请求在codeigniter中找不到

问题描述 投票:0回答:2

我正在使用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有问题吗?

更新:

我终于找到了:

RewriteEngine On RewriteBase / Saffron / RewriteRule ^ index \ .php $ - [L] RewriteCond%{REQUEST_FILENAME}! - f RewriteCond%{REQUEST_FILENAME}!-d 重写规则。 /Saffron/index.php [L]

工作得很好

php .htaccess codeigniter wamp
2个回答
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>

0
投票

您可以在路由器文件application/config/routes.php中添加这样的内容。

$route['Product/(:num)/(:any)] = 'Product/$1/$2';

我假设Saffron是你的base_url目录。

请在下面查看更多信息:

CI URI Route documentation

© www.soinside.com 2019 - 2024. All rights reserved.