Localization url redirect issue - isapi-rewrite

We are toying around with localization at the moment
www.somesite.com : Just normal
www.somesite.com/de/ : Should redirect to www.somesite.com?lang=de
Same for sub pages.
www.somesite.com/de/someCategory.html : should redirect to www.somesite.com/someCategory.html?lang=de
And finally
www.somesite.com/de/someCategory/SomeProduct.html : Should redirect to www.somesite.com/someCategory/SomeProduct.html?Lang=de
Any on how to get starts on this?

Please try this:
RewriteRule ^(\w{2})(/.*)?$ (?2$2:/)\?lang=$1 [QSA]

Related

How to setup URL redirect in Cyberpanel (Lightshot)

I am trying to rewrite URLS in my website but unable to do so.
I am using Lightspeed in Cyberpanel. The .htaccess code I used is:
RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA]
What my url looks right now: mysite.tld/index.php?a=2322
What I want to look it like: mysite.tld/2322
Thanks in advance!

how to change standard URL in codeigniter for multilanguage?

I have a multi language website in code igniter with uses prefix in the URL to define the language. Works great but there is a problem when going to the home page.
The default URL is
localhost:8888
but it should be
localhost:8888/index.php/EN/welcome
I tried redirecting in the controller but that didn't work.
Any ideas on how to fix this problem?
Thanks a lot
First of all you must create a .htaccess file in your root path. File content like this;
Options -Indexes
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
You can edit your route file like this;
$route['(:any)/(:any'] = 'IndexController/getPage/$1/$2';
$route['(:any)'] = 'IndexController/index/$1';
$route['default_controller'] = 'IndexController';
Route 1: Your sub page. First parameter is language, second parameter is page url
Route 2: Your home page. Parameter is language.
Route 3: Default home page in your main language.

How to keep the last segment of the URL and 301 redirect it?

I have this URL = domain.com/art-articles/arts/biography/2375-elias-
and I want to 301 redirect it because I recently changed my Joomla website to something like this domain.com/articles/art-articles/bios/item/2375-elias-
I tried something like this but didn't worked.
RewriteRule ^art-articles/arts/biography/(.*) /articles/art-articles/bios/item/$1 [R=301,L]
The code is this. My Firefox Cache was the problem.
RewriteRule ^art-articles/arts/biography/(.*)$ /articles/art-articles/bios/item/$1 [R=301,L]

Code Igniter URL routing confusion

I have a slight issue. I have configured my default controller as :
c$route['default_controller'] = 'news';
so when I point my browser to http://localhost/mysite all the news get loaded as instructed by the news controller.
Now on this page, I have given links to "read article" to read the full article. For this I have to point my browser to http://localhost/index.php/news/view/news-slug. I want to remove index.php from the url. I had already tried re-routing using wildcard without any success. Can you tell me how to do that?
There is a documentation on removing the index.php from the URL if you are using Apache with it's mod_rewrite:
Removing the index.php file
Using the following rewrite code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Also, there are many similar questions to yours, have a look at these questions from the search:
Search query on removing index.php in Codeigniter
You need to define your .htaccess file for this. Check this wiki: http://codeigniter.com/wiki/mod_rewrite

links in codeigniter

I'm experimenting with codeigniter but don't really understand how links work.
for example, I have a link like this:
localhost/ci/welcome/cat/7
My base url is localhost/ci, so by clicking on this link I would expect the method "cat" of controller "welcome" to be called.
This method is very simple:
function cat()
{
echo "just a test.";
}
Pretty basic - I would expect to see the text on screen, but I just see a 404 -page not found error.
What could be the problem?
http://localhost/ci/index.php/welcome/cat/7
Have you configured mod_rewrite (or URL rewriting in general) properly for CodeIgniter? It's not supported out of the box.
They have some instructions in their wiki.
I had problems with the rewrite rule suggested in the user guide. I was also getting 404s. I had to remove the slash before index.php in the rule.
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
As Veeti says, also remember to enable mod_rewrite for Apache.

Resources