how to redirect domain without changing URL

stevemecher

Member
Apr 6, 2022
6
1
3
Tunisia
cPanel Access Level
Website Owner
hi, how i can redirect the domain without changing url, this EXP: site.com/post TO site.net/post
i search a lot, but i don't found this method
i need help.
thank you.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
10,360
1,632
363
cPanel Access Level
Root Administrator
Hey there! This isn't really a cPanel issue so much as it is a .htaccess issue. I found a guide for this behavior here:


Can you try that and see if that works well for you?
 
  • Like
Reactions: stevemecher

stevemecher

Member
Apr 6, 2022
6
1
3
Tunisia
cPanel Access Level
Website Owner
Hey there! This isn't really a cPanel issue so much as it is a .htaccess issue. I found a guide for this behavior here:


Can you try that and see if that works well for you?
already see it, but i don't know i can open SSH on my new host.
 

Vinayak

Well-Known Member
Jun 27, 2003
288
5
168
Bharat
cPanel Access Level
Root Administrator
ok thank you for trying to help, I will see what I can do.
You own the server or just have a shared account on a server?

On a properly configured cPanel servers mod_rewrite is already enabled, you just have to write proper code in ".htaccess" file located in "public_html" folder.

If the file ".htaccess" does not exists, simply create it, you can do all this using " cPanel >> File Manager".

There is a possibility that file ".htaccess" is not visible, you will have to enable view hidden files in File Manager settings.
 

Rachel S

Member
Apr 28, 2022
16
4
3
United States
cPanel Access Level
Website Owner
Here’s how you can redirect the domain without changing the URL step by step.

-> Log into cPanel
-> Open File Manager
-> public_html
-> .htaccess
-> Now Right-click on .htaccess, Select Edit
-> You will see a box in which click on the Edit button, shown in the Right downside corner.

Suppose visitors visit abc.com, but you want the visitors to redirect to abc2.com without changing the URL. Then, you need to write the below-mentioned Line using the .htaccess file.

RewriteEngineOn
RewriteCond%{HTTP_HOST} ^example1.com RewriteRule ^(.*) example 2 understand – Interesting articles to read. Free tutorials and HOW-TOs [P]

The first Line acknowledges the Apache to begin the rewrite module.
The redirection from the source domain to the target domain is indicated on the Second Line.

You can also write these lines in your .htacccess

-> RewriteCond%{HTTP_HOST} ^example1.com RewriteRule ^(.*)
example 2 understand – Interesting articles to read. Free tutorials and HOW-TOs [P]

Besides, you can also redirect the IP address to another website. You need to add the following lines to the .htaccess file.

RewriteCond%{HTTP_HOST} ^192.168.45.11 RewriteRule (.*) example 2 understand – Interesting articles to read. Free tutorials and HOW-TOs [R=301,L]

Now that this redirect is complete, the server will show you the result.

The L indicates the Last rule in the run.
The R=301 indicates that the web server permanently sends a 301 to the requesting browser or search engine.