htaccess Question
2 posts by 2 authors in: Forums > CMS Builder
Last Post: February 23, 2016 (RSS)
I have a webpage that I would like to point a new domain name to but eliminate the url string in the browser on the initial landing.
For example I have a Sports section here: www.newspaper.com/sports/
I would like to buy the domain name NewspaperSports.com and point it to: www.newspaper.com/sports/
The domain should remain as NewspaperSports.com at least for the initial landing page.
I don't want the url to be seen as www.newspapersports.com/sports/
Is there a way to do this via .htaccess?
My current code creates a redirect:
RewriteCond %{HTTP_HOST} ^NewspaperSports.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.NewspaperSports.com$
RewriteRule ^/?$ "http\:\/\/NewspaperSports\.com\/sports\/" [R=301,L]
Any help or suggestion would be greatly appreciated.
Dan
Hi Dan,
I've done some research into this, but it doesn't look like there is an easy way to do this with .htaccess. Apparently the p tag can be used in rewrite rules to make the server connect via a proxy, but I couldn't get it working on my test machine. You can read about this here:
https://httpd.apache.org/docs/2.4/rewrite/proxy.html
Another solution would be to create an index.php script on NewspaperSports.com that gets the contents from www.newspaper.com/sports/ and displays it using CURL:
https://davidwalsh.name/curl-download
If you have a CMSB installation on NewspaperSports.com, you'd be able to display the contents using the built in getPage function:
// load viewer library
$libraryPath = 'cmsb/lib/viewer_functions.php';
$dirsToCheck = array('C:/wamp/www/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
list($html) = getPage('http://www.newspaper.com/sports/');
echo $html;
Something you'll have to consider with all of these solutions is that the the tags that load JS, CSS, images, etc would need to have absolute URL's on www.newspaper.com/sports/ for the content to load correctly.
Cheers,
Greg
PHP Programmer - interactivetools.com