LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 06-06-2012, 12:17 AM   #1
arun5002
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 549
Blog Entries: 5

Rep: Reputation: Disabled
Mod rewrite problem


HI all,
i have a server of ipaddress example 192.168.203.148 point to example.in and example.com

when the bowser hits example.in it should point to ipaddress
when the browser hits example.com it should point to ipaddress/dir


cat /etc/hosts
192.168.203.148 example.com
192.168.203.148 example.in

Can anyone help me how can i make these rewrite in apache
RewriteEngine On
RewriteRule http://example.com http://example.com/dir [R,L]
RewriteLog "logs/rewrite.log"
RewriteLogLevel 9

Last edited by arun5002; 06-06-2012 at 12:39 AM.
 
Old 06-06-2012, 01:54 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,907

Rep: Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326
Hi,

You don't mod_rewrite for this. You can define 2 vhosts, each one with the desired docroot, i.e something like that:
Code:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName example.in 
DocumentRoot /path/to/docroot
,,,
</VirtualHost>
<VirtualHost *:80>
ServerName example.com
DocumentRoot /path/to/docroot/dir
...
</VirtualHost>
Regards
 
Old 06-06-2012, 03:57 AM   #3
arun5002
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 549
Blog Entries: 5

Original Poster
Rep: Reputation: Disabled
Thanks bathory for ur reply


cat /etc/hosts
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.203.148 example.com
192.168.203.148 example.in

Quote:
But when i hit example.in even i could find my sites is pointing to example.com
NameVirtualHost *:80
<VirtualHost *:80>
ServerName example.com
Alias /images /deployement/tomcatdeploy/static/images
Alias /js /deployement/tomcatdeploy/static/js
Alias /css /deployement/tomcatdeploy/static/css

Alias /cms/admin /deployement/tomcat/apache-tomcat-6.0.26/webapps/cms/admin
Alias /cms/generated /deployement/tomcat/apache-tomcat-6.0.26/webapps/cms/generated
Alias /cms/modules /deployement/tomcat/apache-tomcat-6.0.26/webapps/cms/modules
Alias /cms/themes /deployement/tomcat/apache-tomcat-6.0.26/webapps/cms/themes
Alias /cms/images /deployement/tomcat/apache-tomcat-6.0.26/webapps/cms/images
Alias /cms/css /deployement/tomcat/apache-tomcat-6.0.26/webapps/cms/css

Alias /php /deployement/tomcatdeploy/static/php

<Directory /deployement/tomcatdeploy/static/php>
DirectoryIndex index.php
AllowOverride FileInfo
Options -Indexes +FollowSymLinks -MultiViews
Order allow,deny
Allow from all
</Directory>

<Directory /deployement/tomcatstatic>
Allow from all
</Directory>


<Directory /images/airline>
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(gif/jpe?g|png|bmp) DEFAULT.gif [NC,L]
</Directory>

JkMount /* worker1
JkMount / worker1
#JkMount /dumile worker1

JkMount /cms/* worker1
JkMount /cms/ worker1
JkMount /cms worker1

JkUnMount /images worker1
JkUnMount /*.jpg worker1
JkUnMount /*.gif worker1
JkUnMount /*.png worker1
JkUnMount /*.css worker1
JkUnMount /*.js worker1
JkUnMount /*.swf worker1
JkUnMount /*.ico worker1

JkUnMount /php/* worker1
JkUnMount /php/ worker1
JkUnMount /php worker1

#caching
Header unset ETag
FileETag None
<FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header unset Last-Modified
Header set Cache-Control "max-age=7200, must-revalidate"
Header set Cache-Control "public, no-transform"
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
</FilesMatch>

#compress content with type html, text, and css
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/*

</VirtualHost>

Last edited by arun5002; 06-06-2012 at 04:37 AM.
 
Old 06-06-2012, 04:20 AM   #4
ramecare
Member
 
Registered: Feb 2011
Posts: 179

Rep: Reputation: 0
Add NameVirtualHost *:80


NameVirtualHost *:80

<VirtualHost *:80>
ServerName example.com
Alias /images /deployement/tomcatdeploy/static/images
Alias /js /deployement/tomcatdeploy/static/js
Alias /css /deployement/tomcatdeploy/static/css

Alias /cms/admin /deployement/tomcat/apache-tomcat-6.0.26/webapps/cms/admin
Alias /cms/generated /deployement/tomcat/apache-tomcat-6.0.26/webapps/cms/generated
Alias /cms/modules /deployement/tomcat/apache-tomcat-6.0.26/webapps/cms/modules
Alias /cms/themes /deployement/tomcat/apache-tomcat-6.0.26/webapps/cms/themes
Alias /cms/images /deployement/tomcat/apache-tomcat-6.0.26/webapps/cms/images
Alias /cms/css /deployement/tomcat/apache-tomcat-6.0.26/webapps/cms/css

Alias /php /deployement/tomcatdeploy/static/php

<Directory /deployement/tomcatdeploy/static/php>
DirectoryIndex index.php
AllowOverride FileInfo
Options -Indexes +FollowSymLinks -MultiViews
Order allow,deny
Allow from all
</Directory>

<Directory /deployement/tomcatstatic>
Allow from all
</Directory>


<Directory /images/airline>
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(gif/jpe?g|png|bmp) DEFAULT.gif [NC,L]
</Directory>

JkMount /* worker1
JkMount / worker1
#JkMount /dumile worker1

JkMount /cms/* worker1
JkMount /cms/ worker1
JkMount /cms worker1

JkUnMount /images worker1
JkUnMount /*.jpg worker1
JkUnMount /*.gif worker1
JkUnMount /*.png worker1
JkUnMount /*.css worker1
JkUnMount /*.js worker1
JkUnMount /*.swf worker1
JkUnMount /*.ico worker1

JkUnMount /php/* worker1
JkUnMount /php/ worker1
JkUnMount /php worker1

#caching
Header unset ETag
FileETag None
<FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header unset Last-Modified
Header set Cache-Control "max-age=7200, must-revalidate"
Header set Cache-Control "public, no-transform"
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
</FilesMatch>

#compress content with type html, text, and css
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/*

</VirtualHost>
 
Old 06-06-2012, 04:48 AM   #5
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,907

Rep: Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326
@arun5002
Quote:
But when i hit example.in even i could find my sites is pointing to example.com
Take a look again at my previous post. You need to define 2 vhosts. One for example.com and another one for example.in.
Running apache with a single vhost, will make it the default, so trying to access any other hostname pointing to the same apache IP will point to default vhost.
 
Old 06-06-2012, 06:52 AM   #6
arun5002
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 549
Blog Entries: 5

Original Poster
Rep: Reputation: Disabled
Thanks for ur reply ,
Ur reply help me lots in solving the problem ..
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
mod rewrite suj Linux - Server 5 03-18-2012 04:35 AM
conf :Mod rewrite,Mod Jkand virtualhosts ayyappansan Linux - Server 1 10-25-2009 03:10 AM
Mod Rewrite Problem mpapet Linux - Server 0 03-30-2008 04:51 PM
Apache2 mod vhost_alias - problems with .htaccess mod rewrite d_t_baker Linux - Server 1 08-16-2007 07:32 PM
Mod rewrite problem .. want a friendly/readable url vikram_cvk Linux - Server 1 08-23-2006 06:18 PM


All times are GMT -5. The time now is 08:17 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