LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-09-2010, 08:38 AM   #1
ravibhure
Member
 
Registered: May 2007
Posts: 75

Rep: Reputation: 15
need on rewrite rule help


Hi Tech guru's
rewrite rules for http://subdomain.maindomain.com/path/ to http://path.maindomain.com

is there way to do this with rewrite?
 
Old 09-09-2010, 08:57 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,491

Rep: Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867
rules to do what???

This almost wins as one of the least helpful questions I have seen
 
Old 09-09-2010, 09:18 AM   #3
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,732

Rep: Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584
You can use the following if you're running apache:
Code:
RewriteEngine on

RewriteCond %{HTTP_HOST} ^subdomain.maindomain.com$
Rewriterule ^(.*)/(.*) http://$1.maindomain.com [R]
Of course you must have a *.maindomain.com (a wildcard in dns) and
Code:
ServerAlias *.maindomain.com
in apache vhost configuration for the maindomain.com vhost

Regards
 
Old 09-09-2010, 09:32 AM   #4
ravibhure
Member
 
Registered: May 2007
Posts: 75

Original Poster
Rep: Reputation: 15
Thanks bathory,
But I need to rewrite only path to subdomain i.e. if my URL is http://subdomain.maindomain.com/path/ then I need to permanent redirect it to http://path.maindomain.com/

I have to do with only to this /path/ not to all,

I have found your rule redirects to all my /path/
 
Old 09-09-2010, 11:04 AM   #5
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,732

Rep: Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584Reputation: 1584
I thought that /path could be different every time. Anyways here goes:
Code:
RewriteEngine on

RewriteCond %{HTTP_HOST} ^subdomain.maindomain.com$
Rewriterule ^path$ http://path.maindomain.com [R]
Cheers
 
Old 09-09-2010, 01:03 PM   #6
ravibhure
Member
 
Registered: May 2007
Posts: 75

Original Poster
Rep: Reputation: 15
Thanks a lot bathory,
It works great!!
 
  


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
apache2 rewrite rule help razzera Linux - Server 7 08-17-2010 04:39 PM
httpd rewrite rule jnojr Linux - Server 5 01-25-2010 11:28 PM
Need help with apache Rewrite Rule? your_shadow03 Linux - Newbie 1 01-21-2010 07:12 AM
Apache rewrite rule help kinetik Linux - Software 1 11-05-2007 11:18 AM
i need a rewrite rule!help arcow Linux - Enterprise 1 07-03-2007 05:37 AM


All times are GMT -5. The time now is 12:59 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration