Plain and simple - I want user to get main.php file instead of index.php, when he enters website. Such a straightforward task has caused me a lot of pain, and couple of hours googling. Following does not work:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^/$ /subdomain/main.php

This doesn't work either:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^/$ http://localhost/subdomain/main.php

Where is the problem?

P.S. The rules are placed in .htaccess in /subdomain directory. I'm using WAMP, if it matters.

P.P.S. Logs show "File not found" message.

  • 1
    Is there a reason you are not using Apache's DirectoryIndex directive to accomplish this task?
    – danlefree
    Commented Dec 26, 2011 at 23:53
  • No, just wasn't aware of it. Thanks, this should work.
    – Nordvind
    Commented Dec 27, 2011 at 11:18

2 Answers 2


If you want to match URIs in the root directory, your .htaccess file has to be in the root directory, not in /subdirectory.

I agree that the best way to do this would be using the DirectoryIndex directive.


Is mod_rewrite enabled in the first place? Unless something's changed since the last time I used Wampserver, it's off by default.

Click the WampServer icon in the system tray, mouse over Apache, then Apache modules. Find rewrite_module(or mod_rewrite) in the menu and click it. Then you'll need to restart all services.

  • Of course it's on.
    – Nordvind
    Commented Dec 26, 2011 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.