LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-13-2012, 07:49 AM   #1
jayakumar01
Member
 
Registered: Nov 2011
Posts: 106

Rep: Reputation: Disabled
Apache Mod rewrite in Centos 6.2


Hi all
I Have a single ipaddress with multiple domain mapped to it .How can i rewrite my url
http://example.in to http://10.200.2.0/home.

http://example.com should point to http://10.200.2.0


example.com - http://10.200.2.0
example.in - http://10.200.2.0/home

Last edited by jayakumar01; 06-13-2012 at 07:55 AM.
 
Old 06-13-2012, 08:06 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
well initially that'll be a mod_proxy issue, not rewrite.

ProxyPass http://example.com http://10.200.2.0
ProxyPassReverse http://example.com http://10.200.2.0

You might well not need any rewriting depending on what the content is.
 
Old 06-13-2012, 08:29 AM   #3
jayakumar01
Member
 
Registered: Nov 2011
Posts: 106

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

I had tried out these mod_rewwite rules but it never works


RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !newdomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]


Then i tried out these using proxypass

ProxyPass http://example.in http://10.200.2.0/home
ProxyPassReverse http://example.in http://10.200.2.0/home

when i hit example.in it pointing to http://10.200.2.0
 
Old 06-13-2012, 09:25 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,157
Blog Entries: 1

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
Quote:
Then i tried out these using proxypass

ProxyPass http://example.in http://10.200.2.0/home
ProxyPassReverse http://example.in http://10.200.2.0/home

when i hit example.in it pointing to http://10.200.2.0
You need to do this inside the vhost stanza:
Code:
<VirtualHost *:80>
ServerName example.in
## Add the usual vhost stuff and then ##
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / http://10.200.2.0/home/
ProxyPassReverse / http://10.200.2.0/home/
</VirtualHost>
 
Old 06-13-2012, 10:46 AM   #5
jayakumar01
Member
 
Registered: Nov 2011
Posts: 106

Original Poster
Rep: Reputation: Disabled
Hi


When i had a restart example.com works fine ,example.in delivers 502 proxy error

Whether it neccesssary to have two virtual host since example.in accessing same example.com directory /home folder.whether its easier to achieve my configuration by mod rewrite are else by proxypassReverse


httpd-example.com

Quote:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName example.com

Alias /cms/modules/ /tomcat/webapps/cms/modules
Alias /cms/themes/ /tomcat/webapps/cms/themes
Alias /cms/images/ /tomcat/webapps/cms/images
Alias /cms/css/ /tomcat/webapps/cms/css
Alias /images /tomcat/static/images
Alias /js /tomcat/static/js
Alias /css /tomcat/static/css
Alias /cms/admin /tomcat/webapps/cms/admin
Alias /cms/generated /tomcat/webapps/cms/generated


Alias /php /tomcat/static/php

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

<Directory /deployement/tomcat/static>
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


#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>


httpd-example.in

Quote:
<VirtualHost *:80>
ServerName example.in
Alias /cms/modules/ /tomcat/webapps/cms/modules
Alias /cms/themes/ /tomcat/webapps/cms/themes
Alias /cms/images/ /tomcat/webapps/cms/images
Alias /cms/css/ /tomcat/webapps/cms/css
Alias /images /tomcat//static/images
Alias /js /tomcat/static/js
Alias /css /tomcat/static/css
Alias /cms/admin /tomcat/webapps/cms/admin
Alias /cms/generated /tomcat/webapps/cms/generated


Alias /php /tomcat/static/php

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

<Directory /deployement/tomcat/static>
Allow from all
</Directory>



## Add the usual vhost stuff and then ##
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / http://10.200.2.0/home/
ProxyPassReverse / http://10.200.2.0/home/



<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


#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 jayakumar01; 06-13-2012 at 10:53 AM.
 
Old 06-13-2012, 11:51 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,157
Blog Entries: 1

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
Hi,

The 502 error you get could be due to a variety of reasons. So take a look at both apache and the backend server's logs.
I guess the backend is a tomcat server, so keep in mind that if you use a reverse proxy configuration like the one I've posted above, there is no need to for anything related to mod_jk. You should choose only 1 method of connecting to tomcat, either by mod_jk, or through a reverse proxy setup.
Also the various Alias, <Directory ...> etc, are useless in the latter case

Regards
 
Old 06-13-2012, 12:05 PM   #7
jsaravana87
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558
Blog Entries: 5

Rep: Reputation: Disabled
You can achieve these by mod _rewrite rather than ProxyPassReverse

<VirtualHost *:80>
ServerName example.in
#/**added this**/
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/home(.*)$
RewriteRule ^/(.*)$ http://10.200.2.0/home$1 [R,L]
#/**end**/
</VirtualHost>

Last edited by jsaravana87; 06-13-2012 at 12:06 PM.
 
  


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 Apache quinox2 Linux - Server 1 01-22-2012 07:43 AM
[SOLVED] Apache MOD REWRITE yoachan Linux - Server 4 01-21-2010 01:15 AM
Apache Mod Rewrite Help vital_101 Linux - Server 4 12-02-2009 12:38 AM
Mod Rewrite - Apache FormalLogic Linux - Server 2 03-19-2008 01:30 AM
apache mod rewrite Robert0380 Linux - Software 5 07-31-2003 04:42 PM

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

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