Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

apache rewrite problem

Posted on 2013-12-13
3
Medium Priority
?
200 Views
Last Modified: 2014-01-21
One of the secondary domains I host on my ubuntu demo server has this to ensure that the url starts with www:

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

Open in new window


That works for this domain and all the others.  But for this domain I would also like to redirect users to a subdirectory under the domain's doc root. I tried this:

 #RewriteCond %{REQUEST_URI}  !/myfolder
 #RewriteRule  .*    /myfolder%{REQUEST_URI}    [L]

Open in new window


but then other secondary domains on my server are redirected to this one. I'm not sure how to fix this, nothing I've tried works. I would prefer to use a single ruleset for these two objectives if that's possible.

TIA
0
Comment
Question by:sara_bellum
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 39718257
Try adding an additional condition to the second set:

RewriteCond %{HTTP_HOST} ^www.mydomain.com [NC]
RewriteCond %{REQUEST_URI}  !/myfolder
RewriteRule  .*    /myfolder%{REQUEST_URI}    [L]

Open in new window


...and put it below the other rules.
0
 

Author Comment

by:sara_bellum
ID: 39718356
Perfect, thanks very much! So it's a 2-step process, but it makes sense so that's fine with me.

I'm confused about when to use HTTP_HOST and when to use REQUEST_URI when defining conditions and rewrite rules.  If you can give me a few rules of thumb on how they work it would help, thanks!
0
 

Author Closing Comment

by:sara_bellum
ID: 39798449
Had hoped for follow-up but this solution works and that's the bottom line.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

730 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