Expand my Community achievements bar.

SOLVED

dispatcher redirects for other languages other than base language.

Avatar

Level 1

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"

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@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

View solution in original post

3 Replies

Avatar

Community Advisor

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



Arun Patidar

Avatar

Correct answer by
Community Advisor

@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

Avatar

Administrator

@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