Mobile app version of vmapp.org
Login or Join
Twilah146

: Beginner's Apache mod_rewrite - use custom file for website root Plain and simple - I want user to get main.php file instead of index.php, when he enters website. Such a straightforward task

@Twilah146

Posted in: #Apache2 #ModRewrite

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 ^/$ 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.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Twilah146

2 Comments

Sorted by latest first Latest Oldest Best

 

@Yeniel560

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.

10% popularity Vote Up Vote Down


 

@Cody1181609

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme