[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

.htaccess redirect directory to a different port

Posted on 2009-04-21
10
Medium Priority
?
1,276 Views
Last Modified: 2012-05-06
Hi all,

I'm looking for a way to redirect traffic from a sudden directory to a different server and a different port number.

What I trying to acchief is next.

When people access an url http://server.mydomain.com/directory
I need the system to open this location. But display the location

http://server.mydomain.com:9000/  my server but information from port 9000

I was trying to do so using .htaccess file.
But I don't seem to get it right.
This is what I have

RewriteEngine  on
RewriteCond %{HTTP_HOST} !^axigen\.mydomain\.be/axigen$ [NC]
RewriteRule ^(.*)$ http://server.tmydomain.be:9000$1 [L,r=301]

But it's not working
0
Comment
Question by:osa2
  • 6
  • 4
10 Comments
 
LVL 10

Expert Comment

by:mahome
ID: 24193829
I think you can't put the directory in the HTTP_HOST condition. Try this

RewriteEngine  on
RewriteCond %{HTTP_HOST} !^axigen\.mydomain\.be/$ [NC]
RewriteRule ^/axigen/(.*)$ http://server.mydomain.be:9000/$1 [L,R=301]

Open in new window

0
 
LVL 1

Author Comment

by:osa2
ID: 24193955
It looks like your code looks more correct. But also It doens't work
Maybe I let you know what My domain is. So you can see what is happening for yourself.

the domain is : tcscomputers.be

So the url is http://axigen.tcscomputers.be/axigen
and it needs to be redirected to http://server.tcscomputers.be:9000

0
 
LVL 10

Expert Comment

by:mahome
ID: 24194132
Oh yes there are errors: / and ! in RewriteCond, / in RewriteRule

RewriteEngine  on
RewriteCond %{HTTP_HOST} ^axigen\.tcscomputers\.be$ [NC]
RewriteRule ^axigen/(.*)$ http://server.tcscomputers.be:9000/$1 [L,R=301]

Open in new window

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Author Comment

by:osa2
ID: 24195038
Hmm, Also doenst seem to work

I tried to change {HTTP_HOST} to {REQUEST_URI} as well but no result.

What should be the default chmod value for the .htaccess file? I have 644 now maybe it needs to be higher to work?
0
 
LVL 1

Author Comment

by:osa2
ID: 24195518
even changing the rights to 777 doensn't make it able to view the correct page.


Can you verify that you can access http://server.tcs-computers.be:9000

You should see a page displaying axigen web server
0
 
LVL 10

Expert Comment

by:mahome
ID: 24195854
Yes I can verfiy, but I don't know a simple  .htaccess test.



screenshot.jpg
0
 
LVL 1

Author Comment

by:osa2
ID: 24195921
Thank you for verify. So I now know that the address server.tcscomputers.be is accessable.
Maybe search the internet for a .htaccess test tool
I'll go on searching google right away.
0
 
LVL 10

Accepted Solution

by:
mahome earned 1500 total points
ID: 24196110
Here are some wild ideas:
You can check the access.log of apache (/var/log/apache2/access.log) if the request comes in.
Are you sure that the apache receives the requests of http://axigen.tcscomputers.be/axigen?
Do you modify htaccess of the server with the IP 81.82.218.55 (axigen.tcscomputers.be )?
What virutal hosts are there. Could it be, that they don't let the request to the .htaccess file?
0
 
LVL 1

Author Comment

by:osa2
ID: 24335142
Mmh I guess you are right. It is a virtual host. Maybe the .htaccess file isn't declared on opening the page. I'll try to sort this out with my ISP. Thanks for the tip. I will look forward to that.
0
 
LVL 1

Author Closing Comment

by:osa2
ID: 31572700
Didn't found the aswer but he. Some problems aren't fixable.

Thanks for the second thaugts.

Best regards,
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses
Course of the Month19 days, 21 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question