1

Im trying to make a redirect listen to a certain domain. I have 3 domains; - www.tocdesal.com

  • www.tocdesal.es

  • www.tocdesal.nl

Now i want achieve this..

www.tocdesal.com > www.tocdesal.com/en_GB/

www.tocdesal.nl > www.tocdesal.com/nl_NL/

www.tocdesal.es > www.tocdesal.com/es_ES/

Here is some code i use to manage multilanguage and ban people form certain folders. I hope somebody can help me with this feature.

<IfModule mod_rewrite.c>
    # Turn on URL rewriting
    RewriteEngine On

    # NON-WWW > WWW
    #RewriteCond %{HTTP_HOST} ^www\.tocdesal\.nl [NC]
    #RewriteRule (.*) http://www.tocdesal.nl/nl_NL/home/$1 [R=301,L]

    # CUSTOM REWRITES
    #Redirect 301 /[oldlink] [new-full-link]

    # We dont want snooping people
    Options -Indexes

    #RewriteCond %{REQUEST_URI} ^framework.*

    # If your website begins from a folder e.g localhost/my_project then 
    # you have to change it to: RewriteBase /my_project/
    # If your site begins from the root e.g. example.local/ then
    # let it as it is
    #RewriteBase /tvmoordrecht

    # Protect application and system files from being viewed when the index.php is missing
    RewriteCond $1 ^(framework/modules|framework/coremodules|framework/cicore|application|assets|custommodules)

    # Rewrite to index.php/access_denied/URL
    RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]

    # Allow these directories and files to be displayed directly:
    RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|css|js|images|img|fonts|upload|framework/assets/|themes|framework/apps/elfinder|dev-cmslemonupdater|cmslemonupdater)

    # No rewriting
    RewriteRule ^(.*)$ - [PT,L]

    # Rewrite to index.php/URL
    RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>

2 Answers 2

1

Insert these 3 rules right after RewriteEngine On line:

RewriteCond %{HTTP_HOST} ^(?:www\.)?tocdesal\.com$ [NC]
RewriteRule !^en_GB/ http://www.tocdesal.com/en_GB%{REQUEST_URI} [NE,R=301,L,NC]

RewriteCond %{HTTP_HOST} ^(?:www\.)?tocdesal\.nl$ [NC]
RewriteRule ^ http://www.tocdesal.com/nl_NL%{REQUEST_URI} [NE,R=301,L]

RewriteCond %{HTTP_HOST} ^(?:www\.)?tocdesal\.es$ [NC]
RewriteRule ^ http://www.tocdesal.com/es_ES%{REQUEST_URI} [NE,R=301,L]
5
  • Sadly it didn't work. Still i got the endless redirect loop. I think maby its a problem in the other lines that is causing the problem. I dont have that maby talent in .htaccess
    – Rickerd
    Commented Jun 17, 2014 at 10:03
  • For which URL do you get looping?
    – anubhava
    Commented Jun 17, 2014 at 10:05
  • The .es works now! Great! Is there also a way to make the non-www for all the domains seperatly go to www.tocdesal.* if that can be done im very very happy
    – Rickerd
    Commented Jun 17, 2014 at 10:18
  • Thank you @anubhava the solution works only when i put the .com rewrite in the .com flips and trips and loops again. I also put the rule as last in the order of the 3 rewrites but it didn't help. Its not very important that it works with the .com domain, that one is standard the English version.
    – Rickerd
    Commented Jun 18, 2014 at 11:10
  • I have made a correction in the first rule to prevent looping.
    – anubhava
    Commented Jun 18, 2014 at 11:24
0

This is what i have now. non-www redirects to www for the standard domain (.com) the rest redirects to the language on what the domain is set to.

<IfModule mod_rewrite.c>
    # Turn on URL rewriting
    RewriteEngine On

    # Redirects to the page with that language selected

    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

    RewriteCond %{HTTP_HOST} ^(?:www\.)?tocdesal\.nl$ [NC]
    RewriteRule ^ http://www.tocdesal.com/nl_NL%{REQUEST_URI} [NE,R=301,L]

    RewriteCond %{HTTP_HOST} ^(?:www\.)?tocdesal\.es$ [NC]
    RewriteRule ^ http://www.tocdesal.com/es_ES%{REQUEST_URI} [NE,R=301,L]

    # CUSTOM REWRITES
    #Redirect 301 /[oldlink] [new-full-link]

    # We dont want snooping people
    Options -Indexes

    #RewriteCond %{REQUEST_URI} ^framework.*

    # If your website begins from a folder e.g localhost/my_project then
    # you have to change it to: RewriteBase /my_project/
    # If your site begins from the root e.g. example.local/ then
    # let it as it is
    #RewriteBase /tvmoordrecht

    # Protect application and system files from being viewed when the index.php is mi
    RewriteCond $1 ^(framework/modules|framework/coremodules|framework/cicore|applica

    # Rewrite to index.php/access_denied/URL
    RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]

    # Allow these directories and files to be displayed directly:
    RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|css|js|images|img|fonts|uplo

    # No rewriting
    RewriteRule ^(.*)$ - [PT,L]

    # Rewrite to index.php/URL
    RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.