简体   繁体   English

多语言站点上的htaccess可以代替索引文件。 如何解决这个问题?

[英]htaccess on multilingual site works instead of index file. How to fix this?

I am trying to make a multilingual page, and for now I can do this 我正在尝试制作一个多语言页面,现在我可以做到这一点

domain.com/LANGUAGE/page-name

and it works. 而且有效。

The problem is that if I want to be in the index file with a language like 问题是,如果我想使用类似以下语言的索引文件,

domain.com/LANGUAGE

I get a 404 error. 我收到404错误。

How can I do this? 我怎样才能做到这一点?

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(en|el)/(.*)?$ $2.php?lang=$1 [NC,L]
RewriteRule ^([^\.]+)$ $1.php [NC,L]

Should not your last line be 您的最后一行不应该

RewriteRule ^([^\.]+)$ index.php?lang=$1 [NC,L]

This way any requests having only the language path will go to index.php 这样,只有语言路径的所有请求都将进入index.php

or just make a new rule where the path after the language does not exist 或只是制定一条新规则,即不存在语言之后的路径

RewriteRule ^(en|el)(/)?$ index.php?lang=$1 [NC,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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