Take the 2-minute tour ×

I got a forum installed, which is accessed on sitename.com. I need to make some other pages accessed on sitename.com, and forum on sitename.com/forum. I dont think moving forum to another folder is a good idea, so i decided to use mod_rewrite. Here is my .htaccess file:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
    RewriteRule ^forum$ /index.php$1 [S=3]
    RewriteRule ^forum/$ /index.php$1 [S=2]
    RewriteRule ^forum/(.*)$ /$1 [S=1]   
    RewriteRule    ^$ homepage/  [L]

First 2 lines are used to redirect from www.sitename.com to sitename.com. Next 3 rules are used to redirect all sitename.com/forum requests, and the last rule redirects all sitename.com requests to homepage folder.

Here is a problem with current .htaccess: it shows /homepage/index.php if i open sitename.com, but it doesnt if i open sitename.com/index.php. instead it shows /index.php.

any ideas how to fix this?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

The issue you are facing is with that last rewrite rule. What it is saying is:

if I get a request for sitename.com, send it to homepage/

sitename.com/index.php does not match this.

So, you have a few choices. You can maintain this list by hand (pain in the arse), or you can use some wildcards.

Try adding a rule like this:

RewriteRule    ^*.*$ homepage/  [L]


Upon further examination of this problem, I think there is a better solution. In your (probably ) directive, modify the directories as so

    DocumentRoot /path/to/public_html

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    <Directory "/path/to/forums/">
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all

    #This moves your forums to a new folder
    Alias /path/to/forums
    <Directory "/path/to/public_html/">
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all

Or, of course, you can modify this to use the forums subdomain, so instead of example.com/forums , users will go to forums.example.com

share|improve this answer
I tried the rule you posted, but i get Internal Server Error with it :( I also tried RewriteRule ^index.php$ homepage/index.php [L], it doesnt work too. –  dnls Sep 8 '10 at 11:55

Your Answer


