Julian Hinderer
Julian Hinderer

Reputation: 169

.htaccess forwarding with new website

A WordPress blog can be reached with mod_rewrite at http://xyz.de. In the future this blog will be reached at http://blog.xyz.de. This is no challenge, however the old adresses have to forward to the actual article address.

http://xyz.de/YYYY/MM/DD/titel/ have to forward to http://blog.xyz.de/YYYY/MM/DD/titel/.

To make matters even more complicated, at the root domain ( http://xyz.de ) a new page have to be accessible. This uses GET parameters for navigation. For example http://xyz.de/index.php?site=home.

Is there any way to realize this?

Upvotes: 0

Views: 136

Answers (1)

Michael Berkowski
Michael Berkowski

Reputation: 270677

This is a fairly trivial rewrite and redirect:

RewriteEngine On
# If the domain is xyz.de...
RewriteCond %{HTTP_HOST} ^xyz.de
# And the requested file is not /index.php (for the special case)
RewriteCond %{REQUEST_FILENAME} !/(index\.php)?$
# Redirect to the new domain, appending any existing query string
RewriteRule ^(.*)$ http://blog.xyz.de/$1 [L,R=301,QSA]

Upvotes: 1

Related Questions