Reputation: 336
i am working on a web application using codeigniter.
i have a problem
when i request the controller like this
http://localhost:8080/Saffron/Product/137/test-text
every thing is ok but when i request the controller like this
http://localhost:8080/Saffron/Product/137/مهارت-های-آموزشی-در مطالعه
got this error
The requested URL /Saffron/Product/137/کتاب-غلبه-بر-اضطراب-در-Ù…Øیط-های-آموزشی was not found on this server.
i use this htaccess rules
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>
it work on server without error i have this problem on wamp locahost.where is the problem?
i finally found it:
RewriteEngine On
RewriteBase /Saffron/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /Saffron/index.php [L]
work fine
Upvotes: 0
Views: 1338
Reputation: 82
You can add something like this to your router file application/config/routes.php
.
$route['Product/(:num)/(:any)] = 'Product/$1/$2';
I am assuming Saffron is your base_url
directory.
Check below for more information:
Upvotes: 1
Reputation: 362
Go to your config replace $config['base_url'] = ''; in code below how it will help you
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']);
For 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>
Upvotes: 0