dispatcher redirects for other languages other than base language. | Community
Skip to main content
April 3, 2024
Solved

dispatcher redirects for other languages other than base language.

  • April 3, 2024
  • 3 replies
  • 563 views

for example the current redirect rule is for content/project/de/de, Now I want to add redirect rule for other languages like /content/project/de/es ,  /content/pro/de/en , /content/pro/de/ro etc.

 

here condition is:

  1. The band default short url should be (/content/project/de/de) be applied only if the first path is not starting with 2 letter, ex: /tr/,/ro/,/es/...
  2. When the path starts with /tr/... then append it to the /content/projectname/de only

Can anyone help me?

 

 

# RewriteRule for the default short URL when the first path is not starting with 2 letters
RewriteCond %{REQUEST_URI} !^/[a-z]{2}/ [NC]
RewriteRule ^/([^/]{2})/(.*)$ ${B_ROOT}/$1/$2.html [PT,L]

# RewriteRule for paths starting with /{lang}/ to append them to /content/project/{lang}/
RewriteRule ^/([a-z]{2})/(.*)$ /${B_LOCATION}/$1/$2 [PT,L]
Define B_SITE "/content/project"
Define B_ROOT "${B_SITE}/de/de"
Define B_LOCATION "{B_SITE}/de"

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by aanchal-sikka

@tejuuu123 

 

Please try following:

 

Define B_SITE "/content/project" Define B_ROOT "${B_SITE}/de/de"

 

# RewriteRule for paths starting with /{lang}/ to append them to /content/project/{lang}/ RewriteRule ^/([a-z]{2})/(.*)$ /${B_SITE}/de/$1/$2 [PT,L] # RewriteRule for the default short URL when the first path is not starting with 2 letters RewriteCond %{REQUEST_URI} !^/[a-z]{2}/ [NC] RewriteRule ^/([^/]{2})/(.*)$ ${B_ROOT}/$1/$2.html [PT,L]

3 replies

arunpatidar
Community Advisor
Community Advisor
April 3, 2024

Hi @tejuuu123 
your question is not 100% clear, could you please add examples of request and corresponding redirect requests.

Arun Patidar
aanchal-sikka
Community Advisor
aanchal-sikkaCommunity AdvisorAccepted solution
Community Advisor
April 14, 2024

@tejuuu123 

 

Please try following:

 

Define B_SITE "/content/project" Define B_ROOT "${B_SITE}/de/de"

 

# RewriteRule for paths starting with /{lang}/ to append them to /content/project/{lang}/ RewriteRule ^/([a-z]{2})/(.*)$ /${B_SITE}/de/$1/$2 [PT,L] # RewriteRule for the default short URL when the first path is not starting with 2 letters RewriteCond %{REQUEST_URI} !^/[a-z]{2}/ [NC] RewriteRule ^/([^/]{2})/(.*)$ ${B_ROOT}/$1/$2.html [PT,L]
Aanchal Sikka
kautuk_sahni
Community Manager
Community Manager
July 16, 2024

@tejuuu123 Did you find the suggestion helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!

Kautuk Sahni