Adding virtual "/forum/" directory to topic and forum URLs.

Discussions about Apache mod Rewrite, .htaccess, Use, experiences ... URL Rewriting.

Moderator: Moderators

Adding virtual "/forum/" directory to topic and forum URLs.

Postby Yukan » Tue Jan 19, 2010 11:24 am

I'm using your phpbb3 Ultimate SEO mod and I am trying to rewrite topic and forum URLs a little differently then the vanilla install of the MOD.


My phpbb files are installed @:
www.example.com/phpbb/
I have a portal installed and the URL "www.example.com/phpbb/" is setup to show the portal page.

I have the board in properly setup to show at:
Board Index: www.example.com/phpbb/forum/
Forums: www.example.com/phpbb/forum-name/
Topics: www.example.com/phpbb/forum-name/topic-title/t.#/


I'd like the topic and forum URLs to work as:
http://www.example.com/phpbb/forum/forum-name/
http://www.example.com/phpbb/forum/forum-title/topic-title/.t#/

Is there any way I could accomplish this?
Yukan
 
Posts: 16
Joined: Wed May 28, 2008 11:58 pm

Advertisement

Re: Adding virtual "/forum/" directory to topic and forum URLs.

Postby austin881 » Tue Jan 19, 2010 2:53 pm

Can you post your current .htaccess file? It is probably just a matter of putting forum in front of a few lines.
My dev playground: ModernDignity.com
Appreciate my assistance? You can thank me by linking to Chevy Truck Forum or Gas Scooters.
User avatar
austin881
phpBB SEO Team
phpBB SEO Team
 
Posts: 248
Joined: Wed Oct 28, 2009 12:16 am
Location: Boise, Idaho USA

Re: Adding virtual "/forum/" directory to topic and forum URLs.

Postby Yukan » Wed Jan 20, 2010 2:47 am

austin881 wrote:Can you post your current .htaccess file? It is probably just a matter of putting forum in front of a few lines.

Tried this, and it didn't work. The URLs would get redirected by the zero dupe.

Do note that is HTACCESS works with the current setup I have.

Code: Select all
DirectoryIndex portal.php index.php index.html index.htm

# 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>
<IfModule mod_rewrite.c>
RewriteEngine on

Rewriterule ^blog/(.+)/(.+).html$      ./blog/view/blog.php?page=$1&mode=$2 [NC]
Rewriterule ^blog/(.+).html$         ./blog/blog.php?page=$1 [NC]
Rewriterule ^blog/(.+)/$            ./blog/view/blog.php?page=$1 [NC]
Rewriterule ^blog/$                  ./blog/blog.php [NC]

RewriteCond %{REQUEST_FILENAME} !-f
Rewriterule ^blog/(.+)/(.+)$      ./blog/view/blog.php?page=$1&mode=$2 [NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^blog/(.+)$ ./blog/blog.php?page=$1 [NC]
</IfModule>
ErrorDocument 400 /zenne/error.php?mode=400
ErrorDocument 401 /zenne/error.php?mode=401
ErrorDocument 403 /zenne/error.php?mode=403
ErrorDocument 404 /zenne/error.php?mode=404
ErrorDocument 500 /zenne/error.php?mode=500

# You may need to un-comment the following lines
# Options +FollowSymlinks
# To make sure that rewritten dir or file (/|.html) will not load dir.php in case it exist
# Options -MultiViews
# REMEBER YOU ONLY NEED TO STARD MOD REWRITE ONCE
RewriteEngine On
# REWRITE BASE
RewriteBase /zenne/
# HERE IS A GOOD PLACE TO FORCE CANONICAL DOMAIN
#RewriteCond %{HTTP_HOST} !^www.********\.com$ [NC]
#RewriteRule ^(.*)$ http://********.com/zenne/$1 [QSA,L,R=301]

# DO NOT GO FURTHER IF THE REQUESTED FILE / DIR DOES EXISTS
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
#####################################################
# PHPBB SEO REWRITE RULES ALL MODES
#####################################################
# AUTHOR : dcz www.phpbb-seo.com
# STARTED : 01/2006
#################################
# FORUMS PAGES
###############
# FORUM INDEX
RewriteRule ^forum/$ index.php [QSA,L,NC]
# FORUM ALL MODES
RewriteRule ^(forum|[a-z0-9_-]*/f.)([0-9]+)/?(page([0-9]+)\.html)?$ viewforum.php?f=$2&start=$4 [QSA,L,NC]
# TOPIC WITH VIRTUAL FOLDER ALL MODES
RewriteRule ^(forum|[a-z0-9_-]*/f.)([0-9]+)/(t.|[a-z0-9_-]*/t.)([0-9]+)/?(page([0-9]+)\.html)?$ viewtopic.php?f=$2&t=$4&start=$6 [QSA,L,NC]
# GLOBAL ANNOUNCES WITH VIRTUAL FOLDER ALL MODES
RewriteRule ^global/(t.|[a-z0-9_-]*/t.)([0-9]+)/?(page([0-9]+)\.html)?$ viewtopic.php?t=$2&start=$4 [QSA,L,NC]
# TOPIC WITHOUT FORUM ID & DELIM ALL MODES
RewriteRule ^([a-z0-9_-]*)/?(t.|[a-z0-9_-]*/t.)([0-9]+)/?(page([0-9]+)\.html)?$ viewtopic.php?forum_uri=$1&t=$3&start=$5 [QSA,L,NC]
# PHPBB FILES ALL MODES
RewriteRule ^cdn/[a-z0-9_-]+/(thumb/)?([0-9]+)$ download/file.php?id=$2&t=$1 [QSA,L,NC]
# PROFILES THROUGH USERNAME
RewriteRule ^profile/([^/]+)/?$ memberlist.php?mode=viewprofile&un=$1 [QSA,L,NC]
# USER MESSAGES THROUGH USERNAME
RewriteRule ^profile/([^/]+)/(topics|posts)/?(page([0-9]+)\.html)?$ search.php?author=$1&sr=$2&start=$4 [QSA,L,NC]
# GROUPS ALL MODES
RewriteRule ^(group_|[a-z0-9_-]*-g)([0-9]+)(-([0-9]+))?\.html$ memberlist.php?mode=group&g=$2&start=$4 [QSA,L,NC]
# POST
RewriteRule ^p.([0-9]+)\.html$ viewtopic.php?p=$1 [QSA,L,NC]
# ACTIVE TOPICS
RewriteRule ^active-topics(-([0-9]+))?\.html$ search.php?search_id=active_topics&start=$2&sr=topics [QSA,L,NC]
# UNANSWERED TOPICS
RewriteRule ^unanswered-topics(-([0-9]+))?\.html$ search.php?search_id=unanswered&start=$2&sr=topics [QSA,L,NC]
# NEW POSTS
RewriteRule ^newest-posts(-([0-9]+))?\.html$ search.php?search_id=newposts&start=$2&sr=topics [QSA,L,NC]
# THE TEAM
RewriteRule ^staff\.html$ memberlist.php?mode=leaders [QSA,L,NC]
# HERE IS A GOOD PLACE TO ADD OTHER PHPBB RELATED REWRITERULES

#####################################################
# GYM Sitemaps & RSS
# Global channels
RewriteRule ^rss(/(news)+)?(/(digest)+)?(/(short|long)+)?/?$ gymrss.php?channels&$2&$4&$6 [QSA,L,NC]
# HTML Global news & maps
RewriteRule ^(news|maps)/?(page([0-9]+)\.html)?$ map.php?$1&start=$3 [QSA,L,NC]
# END GYM Sitemaps & RSS
#####################################################

# FORUM WITHOUT ID & DELIM ALL MODES (SAME DELIM)
# THESE THREE LINES MUST BE LOCATED AT THE END OF YOUR HTACCESS TO WORK PROPERLY
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9_-]+)/?(page([0-9]+)\.html)?$ viewforum.php?forum_uri=$1&start=$3 [QSA,L,NC]
# FIX RELATIVE PATHS : FILES
RewriteRule ^.+/(style\.php|ucp\.php|mcp\.php|faq\.php|download/file.php)$ $1 [QSA,L,NC,R=301]
# FIX RELATIVE PATHS : IMAGES
RewriteRule ^.+/(styles/.*|images/.*)/$ $1 [QSA,L,NC,R=301]
# END PHPBB PAGES
#####################################################

#####################################################
# GYM Sitemaps & RSS
# HTML Module additional modes
RewriteRule ^(news|maps)/([a-z0-9_-]+)(/([a-z0-9_-]+))?/?(page([0-9]+)\.html)?$ map.php?$2=$4&$1&start=$6 [QSA,L,NC]
# Main feeds & channels
RewriteRule ^rss(/(news)+)?(/(digest)+)?(/(short|long)+)?(/([a-z0-9_-]+))?/([a-z0-9_]+)\.xml(\.gz)?$ gymrss.php?$9=$8&$2&$4&$6&gzip=$10 [QSA,L,NC]
# Module feeds
RewriteRule ^[a-z0-9_-]*-[a-z]{1,2}([0-9]+)(/(news)+)?(/(digest)+)?(/(short|long)+)?/([a-z0-9_]+)\.xml(\.gz)?$ gymrss.php?$8=$1&$3&$5&$7&gzip=$9 [QSA,L,NC]
# Module feeds without ids
RewriteRule ^([a-z0-9_-]+)(/(news)+)?(/(digest)+)?(/(short|long)+)?/([a-z0-9_]+)\.xml(\.gz)?$ gymrss.php?nametoid=$1&$3&$5&$7&modulename=$8&gzip=$9 [QSA,L,NC]
# Google SitemapIndex
RewriteRule ^sitemapindex\.xml(\.gz)?$ sitemap.php?gzip=$1 [QSA,L,NC]
# Module cat sitemaps
RewriteRule ^[a-z0-9_-]+-([a-z]{1,2})([0-9]+)\.xml(\.gz)?$ sitemap.php?module_sep=$1&module_sub=$2&gzip=$3 [QSA,L,NC]
# Module sitemaps
RewriteRule ^([a-z0-9_]+)-([a-z0-9_-]+)\.xml(\.gz)?$ sitemap.php?$1=$2&gzip=$3 [QSA,L,NC]
# END GYM Sitemaps & RSS
#####################################################
Yukan
 
Posts: 16
Joined: Wed May 28, 2008 11:58 pm


Return to Apache mod Rewrite

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 3 guests