.htaccess / 404 with forum in folder symlinked to root

phpBB2 SEO Advanced mod Rewrite support forum.
This mods performs URL rewriting for phpBB, injecting categories, forums and topic titles in their URLs.

Moderator: Moderators

.htaccess / 404 with forum in folder symlinked to root

Postby Pigeon » Mon Jan 19, 2009 2:14 am

Greetings,

First, thanks for this mod :)

I have just solved some annoying errors which were due to my peculiar configuration and I am posting my solution in case it helps anyone else.

On my site the forum and the main site run on separate servers, with a reverse squid proxy to send requests to the appropriate server. URLs are of the form domain.com/foo.html or domain.com/bar/baz.jpg etc. for the main content, and domain.com/forum/foo for the forum content. The forum server receives HTTP requests of the form "GET /forum/foo". The entry "The path where phpBB2 is located relative to the domain name" in the Configuration section is set to "/forum/".

The forum is actually installed in the server root directory, but the directory contains a symlink "forum" pointing to itself. The site configuration file in sites-available looks like this:

Code: Select all
<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/forum
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/forum/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined

</VirtualHost>


and in /var/forum we have the symlink

Code: Select all
forum -> .


Since the URLs received by the forum server follow the same pattern as for a forum installed in a genuine subdirectory, I initially used the "folder install" version of .htaccess supplied with the mod (changing "phpbb" to "forum" to suit my site), and found that everything gave a 404 no matter what I did.

I found that it was actually necessary to use the "root install" version of .htaccess with all the leading slashes removed from the replacement part of the patterns. So my .htaccess now looks like this:

Code: Select all
# You could need to un-comment the following line
# Options +FollowSymlinks
RewriteEngine On
RewriteBase /

# Lines That should already be in your .htacess
<Files "config.php">
Order Allow,Deny
Deny from All
</Files>
<Files "common.php">
Order Allow,Deny
Deny from All
</Files>

#########################################################
# PHPBB SEO REWRITE RULES                               #
#########################################################
# AUTHOR : DCZ http://www.phpbb-seo.com/
# STARTED : 01/2006
#####################################################
# FORUMS PAGES
########################
# FORUM INDEX (un-comment if used)
RewriteRule ^index\.html$ index.php [QSA,L,NC]
# FORUM PROTECTION RULE
# RewriteRule ^[a-z0-9_-]*/([^/]+\.html)$ index.php [R=301,L,NC]
# CATEGORIES
RewriteRule ^[a-z0-9_-]*-c([0-9]+)\.html$ index.php?c=$1 [QSA,L,NC]
# PAGINATED FORUM
RewriteRule ^[a-z0-9_-]*-f([0-9]+)-([0-9]+)\.html$ viewforum.php?f=$1&start=$2 [QSA,L,NC]
# FORUM
RewriteRule ^[a-z0-9_-]*-f([0-9]+)\.html$ viewforum.php?f=$1 [QSA,L,NC]
# PAGINATED TOPIC
RewriteRule ^[a-z0-9_-]*-t([0-9]+)-([0-9]+)\.html$ viewtopic.php?t=$1&start=$2 [QSA,L,NC]
# TOPIC
RewriteRule ^[a-z0-9_-]*-t([0-9]+)\.html$ viewtopic.php?t=$1 [QSA,L,NC]
# POST
RewriteRule ^post([0-9]+)\.html$ viewtopic.php?p=$1 [QSA,L,NC]
#PROFILES
RewriteRule ^member([0-9]+)\.html$ profile.php?mode=viewprofile&u=$1 [QSA,L,NC]
# END PHPBB PAGES
#####################################################


With that it all seems to be working.

I hope this helps anyone else with a similar setup.
Pigeon
 
Posts: 17
Joined: Sun Jan 18, 2009 10:36 pm

Advertisement

Postby SeO » Mon Jan 19, 2009 12:29 pm

Good job ;)

mod_rewrite wise, the path to care about is generally the one starting form the used domain root, eg example.com/phpBB/, even if other domain may be installed where example.com/ leads in the file-system.

The typical issue related to this is when a sub domain is installed within a dir being itself part of the main domain, example :
Code: Select all
forum.example.com => www/phpBB3/ as root
-www.example.com => www/ as root.


forum.example.com will in such case only be usable by mod_rewrite in the www/phpBB3/ dir, and the sub domain's .htaccess will have to be set as if (and it's the case) used in the used domain's root.
SeO
Admin
Admin
 
Posts: 6333
Joined: Wed Mar 15, 2006 9:41 pm


Return to phpBB2 Advanced mod Rewrite

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 3 guests