Solved

.htaccess doesn't work from subdirectory

Posted on 2011-09-13
7
354 Views
Last Modified: 2012-06-22
I'd like to let people put www.mysite.com/trial into a browser and get directed to www.mysite.com/trial.php. That is, I don't want to force them to put in www.mysite.com/trial.php.  

So I put a trial directory under the root directory with an index.html file and a .htaccess file that contains:

Redirect   /index.html http://www.mysite.com/trial.php

But this doesn’t redirect. You go right into trial/index.html page.

I can do .htaccess redirects ok if I put the .htaccess file in the root directory of the site, so I'm thinking that .htaccess doesn't work in a subdirectory.

Is this the case?

Thanks for any info.
Steve
0
Comment
Question by:steva
  • 4
  • 2
7 Comments
 
LVL 21

Accepted Solution

by:
Papertrip earned 250 total points
ID: 36533373
Put this in your .htaccess file in /trial
DirectoryIndex trial.php

Open in new window


Or just change trial.php to index.php, which is probably already in the global DirectoryIndex
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36533375
Or just change trial.php to index.php, which is probably already in the global DirectoryIndex

To be clear I meant rename the file trial.php to index.php
0
 
LVL 12

Assisted Solution

by:larsrohr
larsrohr earned 250 total points
ID: 36533676
Your .htaccess isn't quite right.
You aren't trying to match "/index.html" -- you should be trying to match "/trial/index.html":

Redirect   /trial/index.html http://www.mysite.com/trial.php

0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 21

Expert Comment

by:Papertrip
ID: 36533685
That is only going to work if the GET request has /index.html in it.
0
 
LVL 12

Expert Comment

by:larsrohr
ID: 36533707
It works fine on my server.
Browser asks for "/trial"; server says Well, I have a directory by that name; my server's DirectoryIndex setting uses index.html, so it interprets this request as wanting "/trial/index.html"; and then .htaccess kicks in and the Redirect sends it to "/trial.php".
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36533726
I stand corrected.
0
 

Author Closing Comment

by:steva
ID: 36539113
Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now