LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 12-09-2012, 04:28 AM   #1
suj
Member
 
Registered: Dec 2009
Posts: 33

Rep: Reputation: 1
htaccess rule to change url


HI,

can i achieve the following with any htaccess rule?

when accessing the file domain1.com/file the browser url should be show as domain2.com/file .

can anyone help..
 
Old 12-09-2012, 08:23 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,897

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Hi,

You can use mod_rewrite. In order to access anything in server1 from server2 without changing the server name in the client address-bar, you can use the following in a .htaccess in server2 docroot:
Code:
RewriteEngine on
RewriteRule (.*)        http://server1/$1 [P]
Regards
 
Old 12-09-2012, 08:37 AM   #3
suj
Member
 
Registered: Dec 2009
Posts: 33

Original Poster
Rep: Reputation: 1
thank you for the answer..but I dont have a 2nd server..i have only one domain..i just want to change the url only..cant change anything in domain2.com...the file is only at domain1.com/file..but when someone accessing that link the url part should shown as domain2.com/file..is that possible?
 
Old 12-09-2012, 09:09 AM   #4
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,897

Rep: Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322Reputation: 1322
Quote:
Originally Posted by suj View Post
thank you for the answer..but I dont have a 2nd server..i have only one domain..i just want to change the url only..cant change anything in domain2.com...the file is only at domain1.com/file..but when someone accessing that link the url part should shown as domain2.com/file..is that possible?
No I don't think it's possible if you don't have the control of both servers/domains.
 
Old 12-09-2012, 09:13 AM   #5
suj
Member
 
Registered: Dec 2009
Posts: 33

Original Poster
Rep: Reputation: 1
okay..so i should host the other domain too right..thank you so much for the help.
 
  


Reply

Tags
htaccess


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
htaccess url rewriting dazzler20 Programming 1 12-22-2011 12:47 AM
htaccess rewrite rule asifbasha Linux - Server 1 09-21-2011 12:48 PM
URL Rewriting in htaccess hatchnet Linux - General 7 07-05-2010 05:57 PM
rewrite rule for url change ravibhure Linux - Server 2 01-21-2010 09:12 PM


All times are GMT -5. The time now is 01:52 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration