我目前正在为博客提供文章,并采用以下格式的永久链接:
这是当前的 .htaccess 内容:
# Permalinks
RewriteEngine on
# Articles (english url)
RewriteRule ^articles/?$ /articles.php [QSA,L]
RewriteRule ^articles/([a-z_-]+)/?$ /articles.php?cat=$1 [QSA,L]
RewriteRule ^articles/([a-z_-]+)/([0-9]+)/?$ /articles.php?cat=$1&id=$2 [QSA,L]
现在,我也将所有文章翻译成西班牙语,所以我认为西班牙语的固定链接会更好。我需要设置一个别名,以便发生这种重定向:
简而言之,所有包含 / articulos / xyz / 123 的网址请求都应重定向到 / articles / xyz / 123 ,而不会复制当前的htaccess结构。谢谢!
答案 0 :(得分:1)
试试这个:
# Permalinks
RewriteEngine on
RewriteRule ^articulos/(.*) articles/$1 [QSA,ENV=SPANISH:true]
RewriteRule ^articles/?$ /articles.php [QSA]
RewriteRule ^articles/([a-z_-]+)/?$ /articles.php?cat=$1 [QSA,L]
RewriteRule ^articles/([a-z_-]+)/([0-9]+)/?$ /articles.php?cat=$1&id=$2 [QSA,L]
Header set Set-Cookie "language=english; path=/;" env=!SPANISH
Header set Set-Cookie "language=spanish; path=/;" env=SPANISH