HTACCESS rules if phpbb in folder

Discussions about the phpBB2 Forum. How to get the best from this powerful script.

Moderator: Moderators

HTACCESS rules if phpbb in folder

Postby sceltic » Fri May 05, 2006 10:33 am

Code: Select all
##############################################################
## MOD Title:       phpBB SEO Advanced mod Rewrite
## MOD Author:       dcz <n/a> http://www.phpbb-seo.com/
## MOD Description:    This mod makes static URLs for phpBB
##          Please read the author notes BEFORE using this mod.
##          Check http://forums.phpbb-fr.com/viewtopic_77214.html
##         or http://www.webrankinfo.com/forums/viewtopic_31831.htm
##          for the latest version or to get help with this MOD
##
## MOD Version:    0.0.1
##
## Installation Level:    (Advanced)
## Installation Time:    5 Minutes
## Files To Edit:    (6)
##         .htaccess,
##         index.php,
##         viewforum.php,
##         viewtopic.php,
##         search.php,
##         overall_footer.tpl
## Included Files: n/a
##############################################################
## Author Notes:
## Ce mod nécéssite l'installation préalable de Cyber Alien guest session mod (http://www.phpbbstyles.com/viewtopic.php?t=357).
##
##
##
## LICENSE:
##
##
##
## I have decided to license this under the RPL which states you can not
## remove my credits and if you make any modifications you have to resubmit the modifications
## to me for includion into this toolkit again. You can read the license for yourself for
## further info.
##
## Along with this I now require a link to use this mod.
##
##
##############################################################
## MOD History:
##
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ OPEN ]------------------------------------------
#
# NOTE : Placez ensuite votre .htaccess à la racine de votre hébèrgement.
# Si vous avez d'autres règles .htaccess, ajoutez les simplement dans celui ci (attention à l'ordre des règles!)
# Si vous ne le faites pas, il se peut que la redirection example.com => www.example.com ne marche pas dans les sous dossiers
# et idem pour la règle qui garanti que www.example.com/phpbb/fauxdossier/url.html soit redirigé vers www.example.com/phpbb/index.php
#

.htaccess

#
# phpBB is installed at the root level :
#-----[ ADD ]------------------------------------------
#
# According to the specific hoster you are using, you might have to get rid of the "/" at the beginning of the script.php filenames
# like viewforum.php.
# make sure to change example.com with you actual domain.
#


Options +FollowSymlinks
RewriteEngine On
RewriteBase /

#Make sure the www is present
RewriteCond %{HTTP_HOST} !^www.example\.com [NC]
RewriteRule ^(.*) http://www.example.com/$1 [QSA,R=301,L]

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




#
# phpBB is installed at the root level :
#-----[ ADD ]------------------------------------------
#
# According to the specific hoster you are using, you might have to get rid of the "/" at the beginning of the script.php filenames
# like viewforum.php.
# make sure to change example.com with you actual domain.
#


Options +FollowSymlinks
RewriteEngine On
RewriteBase /

#Pour que example.com soit changé en www.example.com sur tout votre site
RewriteCond %{HTTP_HOST} !^www.example\.com [NC]
RewriteRule ^(.*) http://www.example.com/$1 [QSA,R=301,L]

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




1.Please could you tell me the French instructions, I am sadly unable to translate.

2. I am unclear as to how the htaccess rules should be here!

If a the

was www.example.com/phpbb/

a. what should the rules be

b.
Code: Select all
# According to the specific hoster you are using, you might have to get rid of the "/" at the beginning of the script.php filenames

From where?

3. I seem to be getting redirected back to index issues, is this related
sceltic
PR0
PR0
 
Posts: 55
Joined: Thu May 04, 2006 4:07 pm

Advertisement

Postby dcz » Fri May 05, 2006 11:19 am

Lol I did not noticed you where french speaking, shoudln't we using the french speaking forum instead ?

It's as you want.


And sorry, I put twice the same case
# phpBB is installed at the root level :


So in the end it's only the first one that should be used for a root install, the second one (the one with phpbb/ paths is for a sub folder installation).

So if I understand well, you should use the first rule set (the one without phpbb/ in it).

And the "/" thing is only a matter on server settings, try with, and if it does not work, try without.

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21238
Joined: Fri Apr 28, 2006 9:03 pm

Postby sceltic » Fri May 05, 2006 12:21 pm

I just thought this test will if it goes live be exactly like here in a sub domain and sub folder

Code: Select all
www.subdomain.abc.com/phpbb/


What htacces rules are you using here?, if I see them I will be able to understand.
sceltic
PR0
PR0
 
Posts: 55
Joined: Thu May 04, 2006 4:07 pm

Postby dcz » Fri May 05, 2006 12:31 pm

If you are talking about this part b:

Code: Select all
#Make sure www is present in all urls
RewriteCond %{HTTP_HOST} !^www.example\.com [NC]
RewriteRule ^(.*) http://www.example.com/$1 [QSA,R=301,L]


Well, most of the time both www.example.com and example.com do work, but since they are duplicate, this mean potentially to have a duplicate per page.

So the idea here is to redirect, with a 301 flag, all url to the one with the www.

You can as well use it to only use url without the www, but it's less efficient as far as Search Engine Optimization.

To do so you'd want to put this instead :

Code: Select all
#Make sure www is NOT  present in all urls
RewriteCond %{HTTP_HOST} !^example\.com [NC]
RewriteRule ^(.*) http://example.com/$1 [QSA,R=301,L]


Now I am not shure I understand well the thing about sub domains, remember, this site does not use this code, if you want to compare, please do it with http://phpbb2.phpbb-seo.net/

So in the end there are two case for the .htaccess, but it's the same, it's just to be convenient that I put two version, on for when phpbb is installed at the root level and one for when it's installed in a sub folder (not domain you notice ;) ) just to make it clear where to put the phpbb folder name in those.

So I don't now if you plan to try and use sub domain set up, but I advise you to first try to have all of this code running the regular way before implementing it for sub domains.

Beside, a subdomain just works the same as a domain, so if you have phpbb in a sud folder, being also a sub domain, then you should consider this sub domain as the phpbb domain, meaning, it's root is the phpbb folder.

So could you, if you don't make it, tell me in which folder you phpbb stands starting from server's root and make it clear about sub domains.
++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21238
Joined: Fri Apr 28, 2006 9:03 pm

Postby sceltic » Thu May 18, 2006 5:21 pm

Hi

For phpbb in sub folder

the able2know mod suggests a htaccess file in the root (just for www redirection) and another htaccess in the phpbb sub folder (for rewrite rules)?

Your way suggests just one in the root?

Which is best?
sceltic
PR0
PR0
 
Posts: 55
Joined: Thu May 04, 2006 4:07 pm

Postby sceltic » Thu May 18, 2006 7:50 pm

i am testing and seem to be getting the odd erratic redirect back to index

this happens when you first try a forum or post


Is the options symlinks and rewrite base necessity?#

Will not just
RewriteEngine On

suffice?
sceltic
PR0
PR0
 
Posts: 55
Joined: Thu May 04, 2006 4:07 pm

Postby Peter77 » Fri May 19, 2006 5:31 am

Just wanted to point out that there is a small error. I had to change membre to member in order for the member profile URL to work properly. well maybe not an error... but more like a mix up.. I think.
Peter77
phpBB SEO Team
phpBB SEO Team
 
Posts: 524
Joined: Wed May 10, 2006 9:46 am
Location: Michigan

Postby dcz » Fri May 19, 2006 2:35 pm

Peter77 wrote:Just wanted to point out that there is a small error. I had to change membre to member in order for the member profile URL to work properly. well maybe not an error... but more like a mix up.. I think.


Lol, it's just a matter of Translating to English, forgot ;) Member (En) => Membre (Fr).

Will be annouced when the mod rewrites will be released ;)

Also, I did not take great care of this particular rewriterule because, I don't think it is that good to SEO the profile url.

Actually, I did not implement it on this site, but, many people just love to get spammed :D

But, as it can please some, without really jeopardising global Page Ranking, I could even provide some code to inject nicknames in those (would require some type of warning for members loving nicks with many odd characters like ' or ~ etc ...).

Again, everyone should be aware that if you SEO your member's profile and member list, you will become very attractive for spammers without optimizing any interesting search-able content.

Actually, as always, I think I'll just lock those for anonymous users on this site ;)

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21238
Joined: Fri Apr 28, 2006 9:03 pm

Postby sceltic » Sat May 20, 2006 2:54 am

Shame but I can't use the mod now because

I have tested but

On topics and forums it is getting 'occassional' (usually when ye try the first few times) auto redirects to index??

What would cause this?
sceltic
PR0
PR0
 
Posts: 55
Joined: Thu May 04, 2006 4:07 pm

Postby dcz » Sat May 20, 2006 9:41 am

have you tried reading a bit more about www and url ?

I think you should try to only use one .htaccess file at the root level and several other things proposed in the thread I mentioned ;)

You should not experience such type of random redirection.
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21238
Joined: Fri Apr 28, 2006 9:03 pm

Postby sceltic » Sat May 20, 2006 5:59 pm

hello dcz

I am going to give it a few more goes but I feel not positive.

I keep getting sporadic redirects.

Less now but still there!


Tell me do i have to use the rewrite base rule

Could this work

Code: Select all
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.forum.abc\.com [NC]
RewriteRule ^(.*) http://www.forum.abc.com/$1 [QSA,R=301,L]
sceltic
PR0
PR0
 
Posts: 55
Joined: Thu May 04, 2006 4:07 pm

Postby dcz » Sat May 20, 2006 6:13 pm

sceltic wrote:
Could this work

Code: Select all
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.forum.abc\.com [NC]
RewriteRule ^(.*) http://www.forum.abc.com/$1 [QSA,R=301,L]


Actually it should, try getting rid of the "" in the first line. Also make sure this is the only .htaccess containing rewriterules and that it is located at the root level.

And also, there is something that could trick you, browser cache. Some browser do cache http 301 so that sometime they do not even try the new redir. Relax, clear cache, this is not something do be done this minute, just some general improvement that we all should aim to achieve ;)

Mod rewrite itself is a lot more important.

Be sure about one thing though, all of the proposed solution do work here on this site as well as on all of my web sites. Good hosting is really important to start Search Engine Optimization improvements.
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21238
Joined: Fri Apr 28, 2006 9:03 pm


Return to phpBB2 Forum

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 44 guests