简体   繁体   中英

Htacess Multi language

Im trying to do a multi language errordocument on my htaccess. But it doesnt enter to my original 404 error page or it just only goes to one of the error pages.

i just want to check the folder and if the folder is "pt", it goes to the portuguese 404error page, else it goes to the other pages with the correspond language.

i already tryed more example but non have help me.

In below there some code that i had already tryed.

Try #1

ErrorDocument 404 http://www.teleondagroup.com/novosite/Teleonda/
RewriteRule ^([a-z]{2}) $1/404error.php [L]

Try #2

RewriteRule ^(pt)/ /$1/404error.php [R,L]
ErrorDocument 404 http://www.teleondagroup.com/novosite/Teleonda/pt/404error.php

RewriteRule ^(en)/ /$1/404error.php [R,L]
ErrorDocument 404 http://www.teleondagroup.com/novosite/Teleonda/en/404error.php

I already solve the problem with this site.

https://webmasters.stackexchange.com/questions/47974/separate-404-page-for-subdirectory

You can use something like the following :

RewriteEngine on

#if a file or directory doesn't exist in a particular folder
RewriteCond %{DOCUMENT_ROOT}/$0 !-f [OR]
RewriteCond %{DOCUMENT_ROOT}/$0  !-d
#redirect the request to /errorpage.php in that folder
RewriteRule ^([^/]+)/.*$ /$1/errorpage.php [L,R]

This will Redirect a 404 Uri to /errorpage.php file located in the requested directory ie . example.com/demo/brokenlink.php to example.com/demo/errorpage.php .

Or if this is just for a single directory /pt you can use the following :

 RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?pt.*$ /pt/errorpage.php [L,R]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM