LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 08-23-2016, 08:03 AM   #1
hruday
Member
 
Registered: Jun 2015
Posts: 88

Rep: Reputation: Disabled
new domain redirects to context of another domain


My server configuration is as follows

1) centos 7
2) apache 2.4.6

i have configuration file abc.conf in /etc/httpd.conf.d and its content is as follows

def.com is main domain and abc.def.com is subdomain.

<VirtualHost X.X.X.X:80> (X.X.X.X is server IP)
ServerAdmin abc@def.com
ServerName abc.def.com
ServerAlias www.abc.def.com
########FOR ERROR LOG AND ACCESS LOG#######################
ErrorLog /var/log/httpd/abc-error.log
CustomLog /var/log/httpd/abc-access.log common env=!dontlog

###############TO REDIRECT TO PROPER PAGE##################
RewriteEngine On
RewriteOptions Inherit
RewriteRule ^/$ /administration [R=301,L]
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
############### PROXYPASS TO THE JBOSS INSTANCE #############
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>

Now I mapped another domain pqrs.in to X.X.X.X IP in domain control panel and didn't write any virtual host file for apache.

But when I open pqrs.in in browser it automatically redirects to pqrs.in/administration which is not intended. how can i stop this and avoid redirection and show nothing in the browser for pqrs.in

Last edited by hruday; 08-23-2016 at 08:07 AM.
 
Old 08-23-2016, 03:34 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Now I mapped another domain pqrs.in to X.X.X.X IP in domain control panel and didn't write any virtual host file for apache.
You should create the vhost pqrs.in, or else apache uses the first vhost it finds as the default one.
 
1 members found this post helpful.
Old 08-23-2016, 10:26 PM   #3
hruday
Member
 
Registered: Jun 2015
Posts: 88

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by bathory View Post
You should create the vhost pqrs.in, or else apache uses the first vhost it finds as the default one.
Oh.!

Thanks for the reply. So you say it is must to write vhost file for pqrs.in. Is there any other way.?
 
Old 08-24-2016, 03:31 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by hruday View Post
Oh.!

Thanks for the reply. So you say it is must to write vhost file for pqrs.in. Is there any other way.?
Yes, you can try the following, but it's always better define a different vhost.
Code:
<snip>
###############TO REDIRECT TO PROPER PAGE##################
RewriteEngine On
RewriteOptions Inherit
RewriteCond %{HTTP_HOST} ^pqrs.in
RewriteRule (.*) -  [R=404,L]
RewriteRule ^/$ /administration [R=301,L]
<snip>
 
  


Reply



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
[SOLVED] Changing my site's domain - need to set up an Apache virtual host for 301 redirects Pyplate Linux - Networking 3 07-15-2013 04:57 AM
Associate a Tomcat context to a domain name pmorin Linux - Server 2 06-21-2011 02:47 AM
IPtables - block subdomains (a.domain.com, b.domain.com, c.domain.com,...) benjalien Linux - Networking 6 06-24-2009 07:03 AM
Setting up domain redirects storpappa Linux - Software 3 12-29-2006 09:50 AM
Linux named domain redirects? Nic-MDKman General 2 02-04-2004 09:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:36 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration