I am using CodeIgnitore to develop a multi language website. At the moment I have set up the routing as follows.
$route['default_controller'] = "home";
$route['^(en|fr)/(.+)$'] = "$2";
$route['^(en|fr)$'] = $route['default_controller'];
$route['404_override'] = '';
Now I have the ability to access the homepage with the following URLs
domain.com
domain.com/en
Both these URLs shows the home page in english so will this be penalized for duplicate content & affect SEO. I have other URLs that would cause the same issue. Is there any solution this?
Thanks.
you can redirect domain.com -> domain.com/en.
So you don't have duplicate content.
In your home.php (application/controllers/home.php):
function __construct(){
parent::__construct();
if(!preg_match("/(en|fr)/",$_SERVER['HTTP_HOST'])){
$this->load->helper('url');
redirect('/en', 'location', 301);
}
}
Related
In codeigniter I set in routes.php the default controller:
$route['default_controller'] = 'home';
and the roules to use the lang in url
$route['^(en|es|it)/(.+)$'] = "$2";
$route['^(en|es|it)$'] = $route['default_controller'];
when I write the url in the browser domain.com there is a redirect to domain.com/it/home/index
I would like that the url will be domain.com/it without /home/index
Somebody can help me?
let me know how to redirect to main domain page in codeigniter. Like I want to Redirect my page to www.example.com from www.example.com/folder/controller/
Does anyone know?
First, get the url that the user is on
$url = $_SERVER['REQUEST_URI']; #www.example.com/folder/controller/
Second, you need to parse the url.
$parsedurl = parse_url($url);
Then, get the host.
$host = $parsedurl['host']; #www.example.com
Finally, redirect with redirect:
redirect($host);
I didn't test this, and it's pure php, which I assume will work, since I don't know anything about codeignighter
Edit 1: I changed header to redirect.
Edit 2: Forgot some semicolons ;)
Simply use redirect.
redirect('', 'refresh');
Also change
$config['index_page'] = 'index.php';
to
$config['index_page'] = '';
in application/config/config.php
Add .htaccess to remove index.php .
Refer official doc
I'm adding multilanguage options for a website in CodeIgniter.
I'm using this library
https://github.com/bcit-ci/CodeIgniter/wiki/CodeIgniter-2.1-internationalization-i18n
The only problem i'm having is if y access www.domain.com
The redirect goes to www.domain.com/es/welcome/index
$route['default_controller'] = "welcome/index";
$route['^(es|en)'] = "welcome/index";
$route['^(es|en)/(.+)$'] = "welcome/$2";
I don't know how to only redirect to www.domain.com/es or www.domain.com/en
when entering www.domain.com
Is that possible with this library?
//$this->default_uri = $RTR->default_controller;
$this->default_uri = '';
change line in MY_Lang.php
I try almost everything for fixed my problem but I can't
This is my routes file in codeigniter.
$route['default_controller'] = "main";
$route['404_override'] = 'my_error_page';
$route['(:any)'] = 'page/index/$1/';
My website working well normally but 404_override not redirect to my_error_page.
I see standart codeigniter 404 page like the picture
When I delete last line like following;
$route['default_controller'] = "main";
$route['404_override'] = 'my_error_page';
404_override redirect to my error page and of course web site not running well.
It is maybe a simple problem but I am confused.
Sorry bad english.
Please help.
Thaank you.
Getting to know Code Igniter, and was following this particular section of the tutorial:
http://codeigniter.com/user_guide/tutorial/create_news_items.html
Everything works until I click "Create news item". I receive 404 page and my URL bar looks like this:
http://localhost/tut/index.php/news/localhost/tut/index.php/news/create
Thinking maybe it's route's fault:
$route['default_controller'] = "news/index";
$route['404_override'] = '';
$route['news/(:any)'] = 'news/view/$1';
$route['news'] = 'news'; // what's this for?
$route['news/create'] = 'news/create';
Also, my config.php:
$config['base_url'] = 'localhost/tut';
Any ideas?
According to this thead, you have your base_url set incorrectly. Please follow advice as per thread.