.htaccess in a folder

phpBB2 SEO Simple mod Rewrite support forum.
This mods performs a fully static URL rewriting for phpBB.
Simple and efficient.

Moderator: Moderators

.htaccess in a folder

Postby C@ » Thu Jan 25, 2007 9:17 am

Is any way to make .htaccess file (simple mode v0.2.0) to work in a folder, e.g. folder /forum/ ?
:roll:
I tried to put root-version of .htaccess (simple mode v0.2.0) inside folder forum/, but instead of /forum/forum1.html it returns 404 error while index page /forum/ works fine.

Any help is appreciated :)
C@
 
Posts: 5
Joined: Thu Jan 25, 2007 9:02 am

Advertisement

Postby dcz » Thu Jan 25, 2007 11:57 am

And welcome :D

Usually, there is no real reason to put the phpBB's .htaccess in it's folder.

Unless you've got several hundreds of rewrtierules in the root's .htaccess, it's not a performance issue at all.

Especially if the other rewriterules are as efficient as the phpBB SEO ones (eg using the [L] flag and mentioning the path left and right parts).

Besides, running a single htaccess from root allow the use of rules that will be running on all folders without problems, like the www prefix redirection.

But, if you'd prefer to run it from the forum folder, you can.

You'd need to get rid of the folder names ("phpbb/") in the left part, should be enough.

++
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: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Postby C@ » Thu Jan 25, 2007 5:30 pm

Thank you for your prompt reply :)



Right now I have the following .htaccess in the folder /forum/:
RewriteEngine On
RewriteBase /

#########################################################
# 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 ^cat([0-9]+)\.html$ /index.php?c=$1 [QSA,L]
# PAGINATED FORUM
RewriteRule ^forum([0-9]+)-([0-9]+)\.html$ /viewforum.php?f=$1&start=$2 [QSA,L]
# FORUM
RewriteRule ^forum([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 ^topic([0-9]+)\.html$ /viewtopic.php?t=$1 [QSA,L]
# POST
RewriteRule ^post([0-9]+)\.html$ /viewtopic.php?p=$1 [QSA,L]
#PROFILES
RewriteRule ^member([0-9]+)\.html$ /profile.php?mode=viewprofile&u=$1 [QSA,L]
# END PHPBB PAGES
#####################################################

and it doesn't work :( it kicks me to 404 error if I click on any forum's link (e.g.: forum/forum1.html) on the forum's index page :(

but everything's working fine if I put an appropriate code from your mod's package into root's .htaccess file. The reason why I need it in the folder /forum/: I already have mode rewrite functions in the root's .htaccess (for the rest of my site) and they are in conflict with your mode :(

in both above cases I turned off my already existing mode rewrite functions just to get a clear experiment.
C@
 
Posts: 5
Joined: Thu Jan 25, 2007 9:02 am

Postby dcz » Thu Jan 25, 2007 5:39 pm

You're welcome ;)

Well, you can post all your .htaccess file if not too long, we'll fix the eventual problems. It handier this way.

Or, try to change :

Code: Select all
RewriteBase /


With :

Code: Select all
RewriteBase /forum/


In the forum/'s one.

As well, make sure you're running only one set of rewrite rules fro the forum, not from both root and forum/ ;)

++
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: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Postby C@ » Thu Jan 25, 2007 5:56 pm

Code: Select all
RewriteBase /forum/
didn't make any difference :?

right now I have exact code of .htaccess in the folder /forum/ as it's in my previous message.

here is .htaccess code in the root:
Code: Select all
php_value register_globals Off
php_value mbstring.func_overload 7
#RewriteEngine On
#RewriteCond %{REQUEST_FILENAME} -f [OR]
#RewriteCond %{REQUEST_FILENAME} -d
#RewriteRule .+ - [L]
#RewriteRule .* rewrite_name.php [L]

this combination kicks me to 404 error if I click on any link on the forum's index page :(
C@
 
Posts: 5
Joined: Thu Jan 25, 2007 9:02 am

Postby dcz » Thu Jan 25, 2007 6:08 pm

if what's above is all your root's .htaccess content, try :

Code: Select all
php_value register_globals Off
php_value mbstring.func_overload 7
RewriteEngine On
RewriteBase /

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


As you do not need to separate it, it's small ;)

And delete you forum/ folder's .htaccess

and, if you get 404, try getting rid, as said in install, of the "/" before "forum/".

++
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: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Postby C@ » Thu Jan 25, 2007 6:21 pm

Dear dcz

as I already mentioned previously your mod works fine in the root, but I need my (commented for now):
Code: Select all
#RewriteEngine On
#RewriteCond %{REQUEST_FILENAME} -f [OR]
#RewriteCond %{REQUEST_FILENAME} -d
#RewriteRule .+ - [L]
#RewriteRule .* rewrite_name.php [L]
together they don't work, this is the reason why I want your mod's .htaccess rules only in the folder /forum/ - actually this is the right way to do it :wink: because your mod is intended to work only with phpBB
C@
 
Posts: 5
Joined: Thu Jan 25, 2007 9:02 am

Postby C@ » Thu Jan 25, 2007 6:51 pm

I fixed the problem myself :D now your mode works in the folder with its own .htaccess:
Code: Select all
RewriteEngine On
RewriteBase /forum/

#########################################################
# 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 ^cat([0-9]+)\.html$ index.php?c=$1 [QSA,L]
# PAGINATED FORUM
RewriteRule ^forum([0-9]+)-([0-9]+)\.html$ viewforum.php?f=$1&start=$2 [QSA,L]
# FORUM
RewriteRule ^forum([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 ^topic([0-9]+)\.html$ viewtopic.php?t=$1 [QSA,L]
# POST
RewriteRule ^post([0-9]+)\.html$ viewtopic.php?p=$1 [QSA,L]
#PROFILES
RewriteRule ^member([0-9]+)\.html$ profile.php?mode=viewprofile&u=$1 [QSA,L]
# END PHPBB PAGES
#####################################################

thank you for participation, dcz :wink:

one more question: what's the sacred purpose of this line?
Code: Select all
# RewriteRule ^.+/([^/]+\.html)$ /index.php [R=301,L]
why it's commented?
C@
 
Posts: 5
Joined: Thu Jan 25, 2007 9:02 am

Postby dcz » Fri Jan 26, 2007 1:54 pm

Oh I see.

I just got rid of the commented lines, but I think :


Code: Select all
php_value register_globals Off
php_value mbstring.func_overload 7
RewriteEngine On
RewriteBase /

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

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]
RewriteRule .* rewrite_name.php [L]


will work from root. Alowing you to implement the www prefix redirection without trouble.

Then :
Code: Select all
RewriteRule ^.+/([^/]+\.html)$ /index.php [R=301,L]


is just a rule to redirect to index url like topic/title-txx.html, to prevent virtual folder injection.

It's an effort to make it impossible for anyone to trick our URLs, but this rewriterule is not useful anymore with the zero dupe, so that's why I left is commented, in case someone would need it.
You can delete the lien if you want ;)
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: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Postby Lubor » Mon Sep 03, 2007 10:54 am

Code: Select all
RewriteEngine On
RewriteBase /forum/

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

and i have these problem , error 404
Lubor
PR0
PR0
 
Posts: 52
Joined: Tue Feb 13, 2007 6:37 pm
Location: Slovakia,Bratislava

Postby dcz » Tue Sep 04, 2007 8:51 am

It's pretty normal, have a look at the one two posts above : http://www.phpbb-seo.com/boards/simple- ... .html#5511

++
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: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Postby dcz » Wed Feb 06, 2008 9:37 pm

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: 21219
Joined: Fri Apr 28, 2006 9:03 pm


Return to phpBB2 Simple mod rewrite

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 1 guest