quickapps / cms

Modular CMS powered by CakePHP
GNU General Public License v3.0
164 stars 69 forks source link

Permanent language in the URL #98

Closed saidbakr closed 9 years ago

saidbakr commented 10 years ago

I noticed that QuickApps-cms did not keep the language in the URL. What I'm talking about is keeping a reference to the selected language, other than default language, in the URL. This is an important feature in SEO for multiple languages websites.

quickapps commented 10 years ago

Yes, it does support it. Check the "URL path prefix" option in the backend's configuration panel

saidbakr commented 10 years ago

The problem still exist is in the case of the default language. For the default language it should not produce the language abbreviation in the URL.

quickapps commented 10 years ago

"default language it should not produce the language abbreviation in the URL" I don't see how is that an issue. Accoding to Google and multi-language websites:

https://support.google.com/webmasters/answer/182192?hl=en#1

Make sure each language version is easily discoverable. Keep the content for each language on separate URLs.

saidbakr commented 10 years ago

In the regarded notice they mean other language than English or any other default language for the website. For example, there are a problem of duplicate URL. In my localhost testing application I set Arabic as default languge, the problem is that I have two pages with the same content: http://localhost/4test/qapp/ http://localhost/4test/qapp/ara/ and this is repeated with any other page like about.html

quickapps commented 10 years ago

I see, when "URL Prefix" is enabled:

http://localhost/4test/qapp/

should redirect to:

http://localhost/4test/qapp/ara/

I'll take a look to this, in the meanwhile you can use the "SEO Tools" module, it allows you redirect from one page to another. So you can force a redirection from "http://localhost/4test/qapp/" to "http://localhost/4test/qapp/ara/"

https://github.com/QACMS-Modules/QACMS-SeoTools

saidbakr commented 10 years ago

In one of my old CakePHP 1.2.x projects as I remember, I overcome this issue by the following code in app_controller's before filter:

Configure::load('custom');  
    static $i = true;
    if($i){
   if(isset($this->params['lang'])){

     Configure::write('Config.language', $this->params['lang']);
    /* setlocale(LC_TIME, 'es_ES.utf8');
     var_dump(setlocale(LC_TIME, 'es_ES.utf8'));*/
   }
   else{
     //pr($this->RequestHandler->__requestContent);
     Configure::write('Config.language',Configure::read('DefaultLang'));
   }
    }
    $i = false;

Then I used the following routes in config/routes.php

Router::connect('/:lang/', array('controller' => 'pages', 'action' => 'display', 'home'),array('lang' => '[a-z]{3}', 'persist' => array('lang')));
//some other rules
Router::connect('/:lang/:controller/', array(), array('lang' => '[a-z]{3}', 'persist' => array('lang')));
    Router::connect('/:lang/:controller/:action/*', array(), array('lang' => '[a-z]{3}', 'persist' => array('lang')));
saidbakr commented 10 years ago

In addition to your previous comment, What I'm talking about is preventing the render of the default language abbreviation from any URL in the website not just redirecting to it. In other words, if I tried to access http://localhost/4test/qapp/ara/ it should be soft redirected to http://localhost/4test/qapp/ or http://localhost/4test/qapp/ara/blahh/blahh to http://localhost/4test/qapp/blahh/blahh