LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 09: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, 09:57 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,565

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

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

Rep: Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611
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, 10: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, 12:04 PM   #5
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,903

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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:13 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration