.htaccess 多语言(别名 URL/友好 URL)

标签 .htaccess mod-rewrite seo slug multiple-languages

<分区>

我在一个多语言网站上工作。 对于 URL .com/business-industry/?parent_id=3&value=cars,它工作得很好。 这将使 URL .com/business-industry/3/cars 但该网站也有 .com/nl/和 .com/de/ 我已将下一条规则添加到 .htaccess。 第一个有效,但/nl 和/de 的第二个和第三个无效。

例如,第二个必须来自 .com/nl/business-industrie/?parent_id=3&value=cars 到 .com/nl/business-industrie/3/cars

RewriteEngine On
RewriteRule ^business-industry/([0-9]*)/(.*)/?$ /index.php?business-industry=1&parent_id=$1&value=$2 [NC,L]

RewriteRule ^nl/business-industrie/([0-9]*)/(.*)/?$ /index.php?business-industrie=1&parent_id=$1&value=$2 [L]

RewriteRule ^de/business-branche/([0-9]*)/(.*)/?$ /index.php?business-branche=1&parent_id=$1&value=$2 [NC,L]

非常感谢您的帮助。

提前致谢。

最佳答案

用这条规则替换你的 3 条规则:

RewriteEngine On

RewriteRule (?:^|/)(business-[^/]+)/([0-9]+)/([^/]*)/?$ /index.php?$1=1&parent_id=$2&value=$3 [NC,L,QSA]

关于.htaccess 多语言(别名 URL/友好 URL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21233572/

相关文章:

seo - Schema.org:什么模式最适合覆盖单词定义的页面?

php - .htaccess PHP $_GET

html - 从开发站点转移到实时站点会破坏 CSS

php - htaccess 将index.php重写为.html

.htaccess:此处不允许使用 RewriteEngine

seo - 适当修剪元描述

php - 尝试将 Codeigniter Project 3.0 上传到主机时出现错误 404?

apache - 将.htaccess转换为nginx(mod_rewrite)

apache - .htaccess 使用 request_uri 和 query_string 中的参数

javascript - 单页应用程序的搜索引擎优化