Solved

.htaccess doesn't work from subdirectory

Posted on 2011-09-13
7
392 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
[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
  • 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
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 our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

751 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