htaccess redirect problem

Our website was recently re-designed, and we replaced the homepage (index.html) with a new file (index.php). To ensure that links to the old home page are redirected to the new file, we included a 301 redirect from /index.html to /index.php. Works great.

Then, we added a subdomain for our mobile site. The subdomain points to The homepage for the mobile site is (or

The problem is that whenever someone goes to the subdomain, the htaccess file in the root of the site is apparently redirecting /mobile/index.html to the root of our site - so end users trying to access the mobile site are going to the main website instead.

How can I either change the root htaccess file to be more specific and avoid this problem - or add an htaccess file to the /mobile directory to override the rule in the root?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Is this a *nix OS?  If so, why not just create a symbolic link for index.html that points to index.php?

If you really want to use rewrite then you need to have a RewriteCond for /mobile and or hostname
slovisaAuthor Commented:
Yes, Linux. I'm using a 301 to permanently move index.html to index.php.

I'm not familiar with symbolic links or RewriteCond. Which way would be better, and where can I find more info about how to implement?

Thanks for the help.
A symbolic link is basically a directory entry that "points" index.html to index.php.  This way no rewrites need to be done.  You can do:

    man ls

to see how to setup a link.  The RewriteCond you can go to:

You would need to have a couple of conditions to check for and

I personally would go with the symbolic link.   The only thing you might have to do is setup Apache so it will will call PHP for .html files.

You may need to add:

AddType application/x-httpd-php .htm .html
Addhandler application/x-httpd-php .html .php

To your Apache conf file.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Sebastian TalmonSystem Engineer Datacenter SolutionsCommented:

just to make this complete:

if you want to solve it with redirect, you could use some condition like the following for separation of urls:

RewriteEngine on
RewriteCond %{HTTP_HOST}        !^mobile\.domain\.com [NC]
RewriteCond %{REQUEST_URI} ^/index.html
RewriteRule ^(.*)      [L,R=301]

this could be useful, if you want to avoid generating duplicate content (some search-engines rate sites with duplicate content lower)
Sebastian TalmonSystem Engineer Datacenter SolutionsCommented:

or if you prefer a solution without rewriteEngine:

first step:
enable parsing of .html-files with php as giltjr said:
"The only thing you might have to do is setup Apache so it will will call PHP for .html files.

You may need to add:

AddType application/x-httpd-php .htm .html
Addhandler application/x-httpd-php .html .php "

second step:
create a NEW index.html-File (no symlink!) with the following content:

 header ("Location:");
 header ("HTTP/1.0 301 Moved Permanently");

this will redirect users if they request "index.html" - so you avoid creation of duplicate content, but you do not have the complexibility of the RewriteEngine
slovisaAuthor Commented:
I'm still not totally clear on what I should do or why, but I feel all the options have been laid out here for me to evaluate.
Sebastian TalmonSystem Engineer Datacenter SolutionsCommented:

I would recommend the third solution - it combines the best things of answer one and two: you do not need complex rewrite rules, but you will get a clear 301-redirect for browser and search-engines to avoid double content, rated lower on search engines
slovisaAuthor Commented:
But won't the HTML redirect to PHP prevent people from seeing the index.html on the mobile site? Or is that only if HTML is not available?
Oh, you really have index.html on the mobile site?  I thought you replaced index.html with index.php on both.

After thinking about it the easiest way to do this is no rewrite and no symbolic link.  Change your DirectoryIndex parameter  The defauult is:

     DirectoryIndex index.html

Change it to:

     DirectoryIndex index.php index.html

What this will do is look for index.php first, if it exist it will serve that up, if it does not exist, it will look for index.html and serve that up.

So in your mobile directory you should have have a index.html, but no index.php.  

In your non-mobile directory you will have a index.php, but no index.html.  

slovisaAuthor Commented:
Nice! Thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.