繁体   English   中英

使用.htaccess的虚拟子域

[英]Virtual subdomains using .htaccess

我正在尝试使用.htaccess和wordpress创建虚拟子域。 但它似乎无法正常工作。 使用wordpress,我得到如下URL:foo.eu/test-pagina/?lang=fr

我设法将其重写为我想要的:fr.foo.eu/test-pagina/

但是,当重写此url时,页面将返回500内部服务器错误。

我还在dns配置中为子域设置了通配符。

我必须为根目录中的每个子域创建子文件夹吗?

我当前的.htaccess代码是:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^([a-z]{2})\.hypnose\.eu$ [NC]
RewriteCond %{THE_REQUEST} \ /+([^\?]*)\?lang=([a-z]{2})&?([^\ ]*)
#RewriteRule ^ http://%2.hypnose.eu/%1?%3 [L,R]

RewriteCond %{QUERY_STRING} !(^|&)lang=
RewriteCond %{HTTP_HOST} ^([a-z]{2})\.hypnose\.eu$ [NC]
RewriteRule ^(.*)$ /$1?lang=%1 [L,QSA]

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]
</IfModule>

谁能告诉我我做错了什么?

您是否已在域的控制面板中将“ fr”添加为子域?

将此添加到您的htaccess中

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

暂无
暂无

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

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