0

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
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    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]
</IfModule>

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?

1 Answer 1

0

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]

EDIT

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>
    <Directory "/path/to/forums/">
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    #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
    </Directory>

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

1
  • 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.
    – nlklm
    Sep 8, 2010 at 11:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .