Php Magento多语言重写SEO修复程序?
两年前,我用一种语言与Magento建立了一个网站,现在我想添加另一种语言。 我的实际结构是这样的Php Magento多语言重写SEO修复程序?,php,.htaccess,magento,redirect,mod-rewrite,Php,.htaccess,Magento,Redirect,Mod Rewrite,两年前,我用一种语言与Magento建立了一个网站,现在我想添加另一种语言。 我的实际结构是这样的 example.com/category/ example.com/about.html example.com/product.html 我想得到一个这样的结构: example.com/lang1/category/ example.com/lang1/about.html example.com/lang1/product.html example.com/lang2/category
- example.com/category/
- example.com/about.html
- example.com/product.html
- example.com/lang1/category/
- example.com/lang1/about.html
- example.com/lang1/product.html
- example.com/lang2/category/
- example.com/lang2/about.html
- example.com/lang2/product.html
- example.com/everything\u不带\uu/lang1//\u永久路径
- example.com/lang1/everything
rewrite permanently all the urls which ends not with /lang1/ or /lang2/ to urls with the prefix /lang1/
我知道我可以在Magento后端用这个模式手动添加重写规则,但我更想知道是否可以直接从数据库或使用.htaccess或index.php中的一些脚本批处理,最重要的是,这些解决方案中的哪一个对SEO和SERP的负面影响较小
我找到了解决办法 嗨,我找到了一个解决方案:
RewriteCond %{HTTP_HOST} ^(.)?example.com$ [NC]
RewriteCond %{REQUEST_URI} !^/it/
RewriteCond %{REQUEST_URI} !^/en/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /it/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(.)?example.com$ [NC]
RewriteRule ^(/)?$ it/index.php [L]
RewriteCond %{HTTP_HOST} ^(.)?example.com$ [NC]
RewriteCond %{REQUEST_URI} !^/it/
RewriteCond %{REQUEST_URI} !^/en/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /it/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(.)?example.com$ [NC]
RewriteRule ^(/)?$ it/index.php [L]
乍一看是可行的,但我不能保证。
我希望这会有所帮助
干杯如果可能的话,您可以使用.htaccess 301 url使用自己的
正则表达式函数
因为你需要一些特定的要求来处理你的语言部分
这里我给你们举一个分类的例子
使用新的父URL重定向子类别URL
示例:
category/sub1 redirect to cat/sub1
category/sub2 redirect to cat/sub2
category/sub3 redirect to cat/sub3
如果您更改了父类别URL,或者甚至希望完全删除父类别URL,则可能需要执行以下操作:
RewriteRule ^category/(.*) http://www.yourwebsite.com/cat/$1 [R=301, L]
或者从yourwebsite.com/category/sub
中完全删除'/category/'
,最后得到yourwebsite.com/sub
(“sub”可以是任何url):
重写规则^category/(.*)$1/[R=301,L]
你也可以参考
希望这一定会对您有所帮助。试试这个:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/lang1/
RewriteCond %{REQUEST_URI} !(.*)/lang2/
RewriteRule ^(.*)$ http://www.domain.com/$1/lang1/ [R=301,L]
我找到了解决办法
嗨,我找到了一个解决方案:
RewriteCond %{HTTP_HOST} ^(.)?example.com$ [NC]
RewriteCond %{REQUEST_URI} !^/it/
RewriteCond %{REQUEST_URI} !^/en/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /it/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(.)?example.com$ [NC]
RewriteRule ^(/)?$ it/index.php [L]
RewriteCond %{HTTP_HOST} ^(.)?example.com$ [NC]
RewriteCond %{REQUEST_URI} !^/it/
RewriteCond %{REQUEST_URI} !^/en/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /it/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(.)?example.com$ [NC]
RewriteRule ^(/)?$ it/index.php [L]
乍一看是可行的,但我不能保证。我希望这将有助于欢呼感谢Liyakat的输入,我的问题与示例正好相反,因为我需要在example.com和所有子页面之间添加新的语言代码。也许这可以简化为您的示例。假设/it/是添加到所有不以/en//it/an结尾的页面的路径,对吗<代码>重写规则$.com/(.![it|en])http://example.com/it/ [R=302,L]您应该不必搜索正则表达式。在你的帮助下,你一定能做到this@eliosolutions如果我能帮助你,请不要忘记