0

I got a site with some pages:

http://example.com/myuglyurl.php?id=11
http://example.com/myuglyurl.php?id=12
http://example.com/myuglyurl.php?id=13

and, just for some pages, I want my users to see in their browsers that they are in subdomain, for example:

http://example.com/myuglyurl.php?id=11
http://mynewsubdomain.example.com/myuglyurl.php?id=12
http://example.com/myuglyurl.php?id=13

Subdomain exists and when user directly tries to visit subdomain, I'll redirect them to specific page, that is no problem. But the URL mask I cannot make.

I've tried all kinds of .htaccess tricks, but as I am a complete stranger to .htaccess, I cannot manage to do it.

I've tried:

RewriteCond %{HTTP_HOST} ^example\.com$
RewriteCond %{QUERY_STRING} (^|&)id=12($|&)
RewriteRule ^myuglyurl\.php$ http://mynewsubdomain.example.com/myuglyurl.php?%{QUERY_STRING}

But I get blank page with message: File not found.

Milos
  • 168
  • 2
  • 12

1 Answers1

1

Please use this following.

Redirect and keep everything after the URL Visit yourdomainA.com/page and it will show the content from yourdomainB.com/page

RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomainA.com
RewriteRule ^(.*) http://www.yourdomainB.com/$1 [P]

For more details, please refer to this link - https://www.brontobytes.com/knowledgebase/202/htaccess-URL-Masking-Examples.html

Allen Haley
  • 639
  • 5
  • 21