0

当我的网站第一次打开时,它直接进入这个地址:http ://www.website.com/tr/main

但我希望我的链接是这样的:http ://www.website.com/ 我无法删除“tr/main”链接。我怎么解决这个问题?

php代码:

$route['default_controller'] = "main";
$route['404_override'] = '';
$route['(tr|en)/(.+)$'] = '$2';
$route['(tr|en)$'] = $route['default_controller'];

访问代码:

RewriteEngine On

# Put your installation directory here:
# If your URL is www.example.com/, use /
# If your URL is www.example.com/site_folder/, use /site_folder/

RewriteBase /

# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# For reuests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]  
4

2 回答 2

0

在您的 routes.php 文件中编写以下代码:-

$route['default_controller'] = "main";
$route['404_override'] = '';

然后在你的“主”控制器中,即在 main.php 中使用

function index() 
{
    // write all your code inside this function    
}
于 2012-06-21T13:34:29.230 回答
0

在你的 config.php 文件中写下这段代码:-

$config['base_url']='http://Your Path/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['subclass_prefix'] = 'Base';

在你的 routes.php 文件中写下这段代码:-

$route['default_controller'] = "home";
$route['404_override'] = '';
于 2012-06-21T14:17:56.680 回答