'Rewrite domain url for php script with .htaccess
php or js script works correctly only on domain1.com
Can I fool them with .htaccess to think I use domain1.com while actually having domain2.com in url? That is having $_SERVER['SERVER_NAME']; return domain2.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?domain2.com$ [NC]
RewriteRule ^ http://domain1.com%{REQUEST_URI}
These instructions aren't quite working.
Solution 1:[1]
There is an alternative that is not related to htaccess but you can create an index.php in your root of domain 2 and redirect it to domain1 like this:
<?php
$uri = $_SERVER['REQUEST_URI'];
header('Location: http://domain1.com'.$uri);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Milad Elyasi |
