.htaccess Htaccess重定向而不重写url

.htaccess Htaccess重定向而不重写url,.htaccess,url-rewriting,.htaccess,Url Rewriting,我手头有点小问题 我正在建立一个三种语言的域名,example.com代表principal domain,en.(…)代表english,de.(…)代表germany。 通常我只使用ln-S将httpdocs从子域重定向到main,因为所有语言都执行相同的代码,不同之处与php和mysql相匹配 我的新主机不提供任何ssh连接,因此我必须在这方面使用不同的方法 有人告诉我可以通过.htaccess来完成,但我已经尝试了很多方法,但只能重定向、更改url,这是不可能的,它必须保持不变,内容是的

我手头有点小问题

我正在建立一个三种语言的域名,example.com代表principal domain,en.(…)代表english,de.(…)代表germany。 通常我只使用ln-S将httpdocs从子域重定向到main,因为所有语言都执行相同的代码,不同之处与php和mysql相匹配

我的新主机不提供任何ssh连接,因此我必须在这方面使用不同的方法


有人告诉我可以通过.htaccess来完成,但我已经尝试了很多方法,但只能重定向、更改url,这是不可能的,它必须保持不变,内容是的,将来自另一个域。有人能帮忙吗?

此代码应该与您正在搜索的代码类似:

www.domain.en.htaccess

RewriteBase /
RewriteRule ^(.*)$ http://www.domain.com/en/$1 [L,R=301]
RewriteBase /
RewriteRule ^(.*)$ http://www.domain.com/de/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^en\.domain\.com [NC]
RewriteRule (.*) http://domain.com/en/$1 [QSA,L]

RewriteCond %{HTTP_HOST} ^de\.domain\.com [NC]
RewriteRule (.*) http://domain.com/de/$1 [QSA,L]
www.domain.de.htaccess

RewriteBase /
RewriteRule ^(.*)$ http://www.domain.com/en/$1 [L,R=301]
RewriteBase /
RewriteRule ^(.*)$ http://www.domain.com/de/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^en\.domain\.com [NC]
RewriteRule (.*) http://domain.com/en/$1 [QSA,L]

RewriteCond %{HTTP_HOST} ^de\.domain\.com [NC]
RewriteRule (.*) http://domain.com/de/$1 [QSA,L]
您很可能会调整
http://www.domain.com/lang/1美元
根据您的需要分配


编辑

在您的评论之后,这是子域重定向的代码:

domain.com.htaccess

RewriteBase /
RewriteRule ^(.*)$ http://www.domain.com/en/$1 [L,R=301]
RewriteBase /
RewriteRule ^(.*)$ http://www.domain.com/de/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^en\.domain\.com [NC]
RewriteRule (.*) http://domain.com/en/$1 [QSA,L]

RewriteCond %{HTTP_HOST} ^de\.domain\.com [NC]
RewriteRule (.*) http://domain.com/de/$1 [QSA,L]

此代码应与您正在搜索的代码类似:

www.domain.en.htaccess

RewriteBase /
RewriteRule ^(.*)$ http://www.domain.com/en/$1 [L,R=301]
RewriteBase /
RewriteRule ^(.*)$ http://www.domain.com/de/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^en\.domain\.com [NC]
RewriteRule (.*) http://domain.com/en/$1 [QSA,L]

RewriteCond %{HTTP_HOST} ^de\.domain\.com [NC]
RewriteRule (.*) http://domain.com/de/$1 [QSA,L]
www.domain.de.htaccess

RewriteBase /
RewriteRule ^(.*)$ http://www.domain.com/en/$1 [L,R=301]
RewriteBase /
RewriteRule ^(.*)$ http://www.domain.com/de/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^en\.domain\.com [NC]
RewriteRule (.*) http://domain.com/en/$1 [QSA,L]

RewriteCond %{HTTP_HOST} ^de\.domain\.com [NC]
RewriteRule (.*) http://domain.com/de/$1 [QSA,L]
您很可能会调整
http://www.domain.com/lang/1美元
根据您的需要分配


编辑

在您的评论之后,这是子域重定向的代码:

domain.com.htaccess

RewriteBase /
RewriteRule ^(.*)$ http://www.domain.com/en/$1 [L,R=301]
RewriteBase /
RewriteRule ^(.*)$ http://www.domain.com/de/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^en\.domain\.com [NC]
RewriteRule (.*) http://domain.com/en/$1 [QSA,L]

RewriteCond %{HTTP_HOST} ^de\.domain\.com [NC]
RewriteRule (.*) http://domain.com/de/$1 [QSA,L]

谢谢@zessx,但事实并非如此。这段代码也会更改url,这不是故意的,我只想显示另一个页面的内容并维护en.example.com/de.example.com。它会继续执行重定向。我已经与phpinfo确认mod_代理处于活动状态。但差不多是这样谢谢@zessx但事实并非如此。这段代码也会更改url,这不是故意的,我只想显示另一个页面的内容并维护en.example.com/de.example.com。它会继续执行重定向。我已经与phpinfo确认mod_代理处于活动状态。但差不多就是这样