最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

regex - configure the .htaccess for a domain redirect - Stack Overflow

programmeradmin0浏览0评论

I have a few domains (e.g. vssp-wp.de, vssp-wp-berlin.de, vssp-wp-bayern.de, ...).

I would like to redirect these to the global Wordpress instance at vssp-wp.de. In the background they are redirected to vssp-wp.de/berlin and vssp-wo.de/bayern.

But I want vssp-wp-berlin.de to be displayed in the URL field in the browser and not vssp-wp.de/berlin. Same example for bayern.

If I am correct, the solution is to use the proxy flag in the .htaccess file.

Unfortunately, several attempts (one attached) did not lead to success.

RewriteEngine On
RewriteRule ^/?berlin/(.*)$ /$1 [L,P]
RewriteRule ^/?bayern/(.*)$ /$1 [L,P]

ProxyPassReverse / /

Additional informations:

  • an Apache web server is used
  • Hoster: df.eu
  • According to support, the proxy flag should be supported natively

I have a few domains (e.g. vssp-wp.de, vssp-wp-berlin.de, vssp-wp-bayern.de, ...).

I would like to redirect these to the global Wordpress instance at vssp-wp.de. In the background they are redirected to vssp-wp.de/berlin and vssp-wo.de/bayern.

But I want vssp-wp-berlin.de to be displayed in the URL field in the browser and not vssp-wp.de/berlin. Same example for bayern.

If I am correct, the solution is to use the proxy flag in the .htaccess file.

Unfortunately, several attempts (one attached) did not lead to success.

RewriteEngine On
RewriteRule ^/?berlin/(.*)$ http://vssp-wp.de/berlin/$1 [L,P]
RewriteRule ^/?bayern/(.*)$ http://vssp-wp.de/bayern/$1 [L,P]

ProxyPassReverse / http://vssp-wp.de/

Additional informations:

  • an Apache web server is used
  • Hoster: df.eu
  • According to support, the proxy flag should be supported natively
Share Improve this question edited Feb 1 at 17:55 CodeDude asked Feb 1 at 13:50 CodeDudeCodeDude 135 bronze badges 1
  • You don't need a proxy for that. And you don't want to use one if it is not necessary. Because a proxy really slows down your site: each and every request has to be proxied. – arkascha Commented Feb 1 at 21:53
Add a comment  | 

1 Answer 1

Reset to default 1

No need for a proxy here, as far as I can see. A ServerAlias should be enough:

The virtual host definition:

<VirtualHost *:443>
    ServerName vssp-wp.de
    ServerAlias vssp-wp-berlin.de
    ServerAlias vssp-wp-bayern.de
    DocumentRoot "/some/path"
    # Other directives here
</VirtualHost>

The rewriting rule:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^(?:www\.)?vssp-wp\.de$
RewriteCond %{HTTP_HOST} ^(?:www\.)?vssp-wp-(\w+)\.de$
RewriteRule ^ /%1%{REQUEST_URI} [L]

The file system layout:

/some/path/
           berlin/
           bayern/

That is a simple internal redirection, leaving the visible URL alone. The basic idea behind this: you use one single virtual host that responds to requests to all those domains. Based on what http host has been requested (the domain), requests are internally rewritten to their matching directory.

发布评论

评论列表(0)

  1. 暂无评论