I have a multilanguage site (English and German) with an url structure like this:
English pages
http://example.com/index.php / http://example.com/index.php?lang=en_EN
http://example.com/about.php / http://example.com/about.php?lang=en_EN
http://example.com/contact.php / http://example.com/contact.php?lang=en_EN
German pages
http://example.com/index.php?lang=de_DE
http://example.com/about.php?lang=de_DE
http://example.com/contact.php?lang=de_DE
—
I’d like these urls to be rewritten as following:
English pages:
http://example.com/en/index.php, …
German pages:
http://example.com/de/index.php, …
–
What I have so far is:
Options +FollowSymLinks
RewriteEngine on
RewriteRule /(.*)/(.*)\.php $2.php?lang=$1
But that doesn’t do anything at all …
You can use:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(en|de)/(.*\.php) $2?lang=$1 [NC,L]
Related
we have 2 pages - code.php and seo_friendly.php
seo_friendly.php is, as the name suggests, just a link with a nice name and should
actually map to code.php. this is acomplished so:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^seo_friendly.php$ /code.php [L]
now i'm asked that when someone navigates to code.php (that's an old link)
they will be redirected to seo_friendly.php
i tried adding
redirect /code.php seo_friendly.php
both before and after the rewrite.
but that resulted in a loop..
any idea? thanks and have a nice day :-)
You need to match against the request itself instead of the URI (which changes as the rewrite engine is going through the rules). Try:
RewriteCond %{THE_REQUEST} \ /+code\.php
RewriteRule ^ /seo_friendly.php [L,R=301]
I've searched on Google to find a way to make my URL friendly to my users.
My url now is this:
http://www.rasolutions.nl/blogitem?id=2&name=newpages
I would like it to be like this:
http://www.rasolutions.nl/blogitem/2/newpages
I used Google to find something like that, my result:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^blogitem/([0-9]+)-([a-z]+) http://rasolutions.nl/blogitem?id=$1&name=$2 [NC]
Sorry for the bad English, I'm Dutch and my English isn't the best.
Thanks for the help.
You can write in your .htaccess some think like:
RewriteEngine on
# ! Warning !
RewriteCond %{REQUEST_FILENAME} !/cms/base/tools/urlmodifier.php$
RewriteRule ^(.*)$ /cms/base/tools/urlmodifier.php?param=$1 [L,QSA]
... and do redirect in urlmodifier.php with including of file from request url and modifications of $_SERVER['REQUEST_URI'].
I have a URL:
www.example.com/property-listings/united-states/colorado/denver/denver-co-office-space
I want to stay on the same page above but simply display the URL in the address bar like this:
www.example.com/property-listings/united-states/colorado/denver/office-space
How do I accomplish this using htaccess and rewrite rules?
If I understood right, try writing a rule like this one:
RewriteEngine on
RewriteRule property-listings/united-states/colorado/denver/office-space http://www.example.com/property-listings/united-states/colorado/denver/denver-co-office-space [L]
OK. You didn't supply a pattern or mentioned there was any, so I have to guess the pattern is up to /denver/ subdirectory. Try this:
RewriteEngine on
RewriteRule ^(property-listings/united-states/colorado/denver/)(office-space)/?$ $1denver-co-$2 [L]
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(property-listings/united-states/colorado)/(denver)/(office-space)/?$ $1/$2/$2-co-$3 [L,NC]
Hi Stackoverflow community,
I've been reading through most of the other .htaccess questions, and tried different solutions on my .htaccess file but with no success.
Here's the thing: I have a website (based on CodeIgniter) that already has a good SEO positioning. Now, the customer wants it translated to another language, but I dont want to lose that SEO so I thought of redirecting a URL like http://www.domain.com/contactUs to http://www.domain.com/en/contactUs, being (en) the current positioned language. CI would handle the other language as usual without problem. Im currently doing tests on localhost, so the following rules will have only "domain" instead of "domain.com".
I've tried these Rewrite rules:
RewriteEngine on
Options +FollowSymlinks
RewriteCond ^(.*)/domain/(.*) !^/en/
RewriteRule ^(.*)/domain/(.*)$ $1/domain/en/$2
I want the RewriteCond to filter URLs coming in the new language so that the RewriteRule is not executed. What am I doing wrong?
Do this:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/en/ [NC]
RewriteRule ^(.*)$ /en/$1 [L]
You should put all your text in unique language files, then load them like so:
$this->config->set_item('language',"your_language");
$this->lang->load('default', "your_language");
To write out the content, the use:
$this->lang->line('message_id');
More info:
http://codeigniter.com/user_guide/libraries/language.html
This should more efficient than creating a duplicate site while still being SEO friendly. In fact, it should be more SEO friendly.
RewriteCond $2 !^en/
RewriteRule ^(.*)/domain/(.*)$ $1/domain/en/$2
I'm trying to use rules and conditions with .htaccess but don't know how to do what I need.
Here's the scene:
I have a website with many languages. (en|es|pt)
I want to use the urls like this:
www.site.com/home/
(original url): www.site.com/index.php?p=home
(opens home.php - session language)
And like this:
www.site.com/en/home/
(original url): www.site.com/index.php?l=en&p=home
(opens home.php - en language)
What are the eules/conditions that I need to create to detect the language in url?
TIA
SOLUTION:
RewriteRule ^(en|es|pt)?\/?([a-z0-9A-Z,_-]+)\/?$ index.php?l=$1&p=$2 [QSA,L]
Thanks
Note:
"current solution does also allow something like /enfoobar to be rewritten to /index.php?l=en&p=foobar as the / is independent of the language indicator" - Gumbo
You might probably use something like this
RewriteEngine on
RewriteBase /
RewriteRule ^(en|es|pt)/(.*) /index.php?l=$1&p=$2 [QSA,L]
For any 2digits characters languages
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^[a-zA-Z][a-zA-Z]/index.html$ index.html?language=$1
RewriteRule ^index.html$ /index.php [L]