LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 06-04-2005, 07:04 AM   #1
peterb
Member
 
Registered: Aug 2003
Location: Athens, Greece
Distribution: Mandriva, Fedora
Posts: 127

Rep: Reputation: 15
apache mod or httpd problem


Hello all,

I have setup a linux server to test my web pages and php programs. I have tried to understand the apache mod rewrite but can't seem to get it to work.

The problem is that I have set the domain names to end differently on the local server and would like to call them as the follows:

As an example:
pab.cxm on the home server to reflect the real website pab.net

Can this be done simply with apache_mod_rewrite to say that all requests through my browser as pab.cxm are to be seen as pab.net?

Or do I have to make changes to my named files, httpd conf files?

I don't know if a confict between my home server and the host server might occur if I set both domain names the same, or how to avoid a conflict.

Peter
 
Old 06-05-2005, 09:03 AM   #2
huibert.alblas
Member
 
Registered: Jan 2004
Location: Duesseldorf /Germany
Distribution: Gentoo amd64 / Debian
Posts: 226

Rep: Reputation: 30
Use mod_virzual host for this, that way you can use the hostnames:
www.pab.net (for prod)
and home.pab.net (for development)
 
Old 06-05-2005, 11:58 AM   #3
peterb
Member
 
Registered: Aug 2003
Location: Athens, Greece
Distribution: Mandriva, Fedora
Posts: 127

Original Poster
Rep: Reputation: 15
Hi,

Sorry but I didn't understand your response. I can request both sites now using
www.pab. either cxm or net but what I want to do is for my home server to exchange the cxm ending for net.

Are you talking about making the change under apache through vhost or using mod_rewrite?

Peter
 
Old 06-05-2005, 03:05 PM   #4
huibert.alblas
Member
 
Registered: Jan 2004
Location: Duesseldorf /Germany
Distribution: Gentoo amd64 / Debian
Posts: 226

Rep: Reputation: 30
AFAIK mod_rewrite normaly operates on the URL without the hostname.
That's why you cannot use mod_rewrite to differate between the 2 hosts.
Mod_rewrite is configured on a per host basis.

Maybe you should elaborate more on what problem you are trying to solve. I have the feeling that mod_rewrite is not the answer anyway.

If you try to point your pab.net host to 127.0.0.1 (your local apache setup) there is no way for you to access the real pab.net anymore (because you have a "broken" dns /named)

Try to explain what you want to accomplish, not what you think that you must configure. I think you are tackling the problem from the wrong end.
 
Old 06-06-2005, 01:22 AM   #5
peterb
Member
 
Registered: Aug 2003
Location: Athens, Greece
Distribution: Mandriva, Fedora
Posts: 127

Original Poster
Rep: Reputation: 15
Here is what I am currenlty doing. I have prepared a website say using
www.pab.net that I put out on the web at a host but at the same time I have setup using named on my home server the domain www.pab.cxm simply to test the pages and the php to make sure that everything works.

One of the problems is that I am using hard links in the menus such as:
http://www.pab.net/whatever
and when I call the pages up on my linux server, using www.pab.cxm the links on the index page are somehow showing http://www.pab.cxm/whatever
but when I enter one of the top pages on the local server, all of the links on the next level of pages are showing the actual website links for the net like
http://www.pab.net/whatever/nextlevel

This is why I thought that I could somehow affect the change using mod_rewrite to change all requests from .cxm to .net

Hope this helps.

Peter
 
Old 06-06-2005, 03:23 AM   #6
huibert.alblas
Member
 
Registered: Jan 2004
Location: Duesseldorf /Germany
Distribution: Gentoo amd64 / Debian
Posts: 226

Rep: Reputation: 30
Hmmmm,

never use links like thes in web projects :
Code:
<a href="http://my.doiman.tld/whatever/site.php" >The site</a>
_allways_ use links like these:

Code:
<a href="/whatever/site.php" >The site</a>
Let the browser figure out which hostname the URL belongs to,
that way your local copy (pab.cxm) will work just the same as your produktion copy (www.pab.net)

As you mentioned that links on diferent levels in the menu work differently, you should doublecheck you code that no link depends on the hostname.

Even using $_SERVER_VARS['HOSTNAME'] or something similar in php might not work properly, but you should not need it anyway.

I read you use named for these hostnames.
I never worked with named, but for (local) development servernames and prod servernames I allways just putr the names in /etc/hosts

Code:
127.0.0.1 localhost.localdomain localhost
127.0.0.1 local.my-website.de
In my browser, when I go to www.my-site.de it loads the production site, whereas when I laod local.my-website.de it loads the local copy.

I can now use exactly the same code on both servers.

Last edited by huibert.alblas; 06-06-2005 at 07:12 AM.
 
Old 06-06-2005, 05:21 AM   #7
peterb
Member
 
Registered: Aug 2003
Location: Athens, Greece
Distribution: Mandriva, Fedora
Posts: 127

Original Poster
Rep: Reputation: 15
Hi,

Yes, I used to leave the links more loosely like the example that you show <a href="/whatever/site.php" >The site</a>
but then someone told me that pages could be hijacked and that it was safer for security purposes to hard code them as
<a href="www.mydomain.tld/whatever/site.php" >The site</a>

Is there any truth to this?

Otherwise I could simply run a search replace and change all the links to make life easier.

Peter
 
Old 06-06-2005, 06:53 AM   #8
huibert.alblas
Member
 
Registered: Jan 2004
Location: Duesseldorf /Germany
Distribution: Gentoo amd64 / Debian
Posts: 226

Rep: Reputation: 30
Hijacking links like this, maybe are a posibility with forums, or other places where unknown users (guests) can create HTML displayed on your site. (like on ebay)

As you are the only content provider/creator you do not have any problems.

Other then that, I would say these are old granny tales.
Who ever told you about it being more secure, can please write me and explain, because AFAIK this is Bull.

Don't get me wrong, I allways like to learn new stuff,
but I don't believe it has any security implications, and I know a bit about web development, becaus I have been a fulltime web developer for about 5 years.
 
Old 06-06-2005, 07:09 AM   #9
peterb
Member
 
Registered: Aug 2003
Location: Athens, Greece
Distribution: Mandriva, Fedora
Posts: 127

Original Poster
Rep: Reputation: 15
Thanks for the info and help. Much appreciated.

Peter
 
  


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
httpd apache problem ebasi Linux - Software 1 07-24-2004 12:20 PM
Apache mod _auth ldap problem Help!! Sabeer Linux - Software 0 10-17-2003 10:17 AM
Apache (httpd) 2.0 conf authentication problem HELP!!! bleah-man Linux - Software 14 08-18-2003 09:04 AM
httpd chokes on ScriptAlias line in Apache httpd.conf lhoff Linux - Software 1 07-14-2003 10:32 PM
Apache problem - httpd won't start. Iced_Falcon Linux - Networking 3 12-22-2001 04:31 PM


All times are GMT -5. The time now is 01:37 PM.

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