I have a local domain name .dz which doesn't allow DNS changes, I want to redirect the domain and all the pages to another domain .com, and keep the .dz address in the address bar and completely hide the .com domain.
I've searched the whole Internet all solutions doesn't do this, some does the redirect to .com and the .com shows in the address bar and some others redirect only the homepage.
I am wondering if the is a php function to read directly from the .com domain and then writes the content to the .dz domain
I have access to both .htaccess or the PHP files.
To redirect a site permanently, one should use a 301 redirect. This type of redirect is best for SEO purposes and also informs the search engines that the site has moved permanently. If you change your domain name and want to point to a different URL, a 301 redirect is your best choice.
Using a 301 redirect indicates that the original URL's content has permanently moved to a new URL. Use this type of redirect when you need to forward users and search engines to a new page location and that the original URL won't be coming back.
A masked redirect empowers you to use content from another domain while keeping your original domain name in the address bar. You use the URL of your homepage (your domain name) as the URL for every page of your website. A masked redirect is also called URL cloaking or domain masking.
I assume you have access to httpd.conf
or conf
directory,
Try this in your httpd.conf
in the section where mod_proxy is mentioned.
ProxyPass / http://yourwebsite.com/ smax=0 ttl=60 retry=5
ProxyPassReverse / http://yourwebsite.com/ smax=0 ttl=60 retry=5
And may be in case you have to put above rules in separate conf file named httpd-ajp.conf
you will find it in conf/extra
directory.
And when done you have to restart your server before attempting to check.
Edit
As you've said that you don't have access to conf
directory you can try below rule in .htaccess
RewriteEngine On
RewriteRule ^(.*)$ http://domain.com/$1 [P]
But you must ensure that mod_proxy is enabled these lines must uncommented in httpd.conf
if you able to ask it out with your hosting provider.
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Try with proxy in .htaccess
:
RewriteEngine on
RewriteRule ^ http://domain.com%{REQUEST_URI} [NE,P]
It is possible that this is good enough in your case, if the site is simple.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With