logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Add abbreviation of the country in the url address
Author
deuxk



Joined: 08 May 2014
Posts: 1
Location: canada,québec

PostPosted: Thu 08 May '14 16:25    Post subject: Add abbreviation of the country in the url address Reply with quote

Hi,

Apache version > i don't know (i am a godaddy user)
Apache platform > unix

I try to make a change to my current htaccess for now my url looks like> sitename.com/en/filename.ext
I want to get to have an address resembling this:
sitename.com/ca/​​en/filename.ext (in case the country is Canada and french language)
sitename.com/us/en/filename.ext (in case the country is United State and English language)
sitename.com/eu/en/filename.ext (in case the country is Europe and English language)
sitename.com/en/filename.ext (in case the country is not mentioned and English language)

Here is the current structure of my htaccess
Code:

AddDefaultCharset utf-8
SetEnv CA America/Montreal

Options -Indexes +FollowSymlinks
RewriteEngine On
RewriteBase /

<IfModule mod_rewrite.c>

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule \.(?:css|png|jpe?g|gif)$ - [L]    #RewriteRule \.(?:css|png|jpe?g|gif|ttf|js)$ - [L]   
   
RewriteRule (fr|en)/(.*) /$2?language=$1 [NC,L,QSA]

#language, detect and set
RewriteCond %{QUERY_STRING} !(?:^|&)language=[^&]+
RewriteCond %{REQUEST_URI} !^/(?:fr|en)/
RewriteCond %{HTTP:Accept-Language} ^fr [NC]
RewriteRule .* /fr/$1 [L,R=permanent]
                  
RewriteCond %{QUERY_STRING} !(?:^|&)language=[^&]+   
RewriteCond %{REQUEST_URI} !^/(?:fr|en)/
RewriteRule .* /en/$1 [L,R=permanent]   
</IfModule>



For now I try lots of things, but nothing happens ... if you have an idea, it would be greatly appreciated!

pleasure
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Mon 26 May '14 10:22    Post subject: Reply with quote

Are you shure that mod rewrite is enabled? Or rewrite rules seems to be ok.
Back to top


Reply to topic   Topic: Add abbreviation of the country in the url address View previous topic :: View next topic
Post new topic   Forum Index -> Apache