Reputation: 402
So, to be more graphic at the beginning:
This is current link structure:
http://example.com/video-slug/wordpress-title-of-the-video-slug
I have a subdomain:
http://tv.example.com/
What I want to achieve is, when someone clicks on:
http://tv.example.com/wordpress-title-of-the-video-slug
It figures out that tv.example.com
equals example.com/video
and opens the the link:
http://example.com/video/wordpress-title-of-the-video-slug
, but keeps the structure in location bar:
http://tv.example.com/wordpress-title-of-the-video-slug
Upvotes: 2
Views: 2939
Reputation: 153
A more generic solution, that applies to your question. It allows any http://subdomain.example.com/ to serve the content located at http://example.com/subdomain/ while keeping the original URL (with subdomain).
The P option (for Proxy) serves that purpose (to keep the original URL in the address bar), and answers the question asked in accepted answer comments (i can't comment back tho..)
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(.*)\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/%1/$1 [L,P]
for your specific case it would be
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^tv\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/video/$1 [L,P]
A drawback i am facing now is that PHP $_SERVER URI is set to the translated URL not the original one. But that is another issue :)
Upvotes: 2
Reputation: 755
I think this is an easier way using PHP:
<?php
//add some params
$_GET['param1'] = value1;
//the actual page you wish to redirect to
include "/var/www/page.php";
?>
Upvotes: 0
Reputation: 14324
You need a rewrite rule in your .htaccess
file. From memory, something like this should work.
RewriteEngine on
RewriteRule ^(.*)$ http://example.com/video/$1 [NC]
Placed in the tv
subdomain.
Upvotes: 1