Help on URL Rewrite

Discussions and support about the different URL Rewriting techniques for phpBB.

Moderator: Moderators


Help on URL Rewrite

Postby anandharaj » Wed Jul 08, 2009 3:08 pm

Hi,

I already done with my testing on MOD SEO, now i want to redirect all request on my existing site (forum related page) to this new site. i dont want the forum back to main site, i want to keep in sub-domain.

Right now, im redirecting all request from http://www.tamilminnal.net to forum.tamilminnal.net. This actually solve my problem, but i need to explicitly define to only redirect forum related page to this new sub-domain, because later i will use the main site for other purpose.

Eg: Redirect -www.tamilminnal.net/viewtopic.php?blabla to forum.tamilminnal.net/viewtopic.php?blabla - so, once its reach forum.tamilminnal.net with "viewtopic.php?blabla" the htaccess in this sub-domain will handle the URL rewrite.

So, how can i redirect from main domain to sub-domain based on certain page only (viewforum.php, viewtopic.php, member.php, etc) using htaccess? Can some one help me with .htaccess codes for URL re-write?
anandharaj
 
Posts: 26
Joined: Sat Jul 04, 2009 2:42 pm

Advertisement

Re: Help on URL Rewrite

Postby dcz » Wed Jul 08, 2009 5:32 pm

It mostly depends on how is the sub-domain installed. If it is installed on the same server, you can just keep the old phpBB's .htaccess in the www domain and just tweak the rewriterules to make them still point to the phpBB scripts, but in the new directory.
For example if you had :
Code: Select all
ftpfiles/www/viewtopic.php

and you now have :
Code: Select all
ftpfiles/www/
ftpfiles/forum/viewtopic.php

you would just need to use ./../forum/ as the path to the script in the rewriterules. Note that you could need to use ../forum/ or even the absolute path /home/ftpfiles/forum/ depending on your server settings.
Following this example, if you had :
Code: Select all
RewriteRule ^forum\.html$ /index.php [QSA,L,NC]

you would need to use :
Code: Select all
RewriteRule ^forum\.html$ ./../forum/index.php [QSA,L,NC]

And all this in the .htacess of the main domain, eg in ftpfiles/www/, and you would of course need to implement a regular .htaccess in your sub domain's .htaccess.

If your sub-domain is installed on another server or cannot be reached using a local path, you would need to specify the full url and to add the R=301 flag, eg :
Code: Select all
RewriteRule ^forum\.html$ /index.php [QSA,L,NC]

would then become :
Code: Select all
RewriteRule ^forum\.html$ http://www.example.com/index.php [QSA,L,NC,R=301]

And so on.
The first solution is better because it will always use only one redirection, while the second one could use two, but it's not that much of a big deal either.

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

Re: Help on URL Rewrite

Postby anandharaj » Thu Jul 09, 2009 12:28 am

Hi,

Thanks for the great info, appreciate it. Just to clarify, my site directory structure as below:

$FTP/www/viewtopic.php - main site (http://www.tamilminnal.net)
$FTP/www/forum/viewtopic/php - new site (but user will access via http://forum.tamilminnal.net)

so, is my rewrite condition should be:
Code: Select all
RewriteRule ^viewtopic\.php?f=$1&t=$2$ /forum/viewtopic.php?f=$1&t=$2 [QSA,L,NC]
anandharaj
 
Posts: 26
Joined: Sat Jul 04, 2009 2:42 pm

Re: Help on URL Rewrite

Postby anandharaj » Sat Jul 11, 2009 1:34 pm

Any update on this?
anandharaj
 
Posts: 26
Joined: Sat Jul 04, 2009 2:42 pm

Re: Help on URL Rewrite

Postby dcz » Sat Jul 11, 2009 1:57 pm

So in $FTP/www/'s.htaccess, yes, you would just need to use
Code: Select all
RewriteRule ^forum\.html$ /forum/index.php [QSA,L,NC]


and so on, and note that this only means to add the forum/ path to the right part (before the script) not to change anything else such as adding the script on the left side like you did (viewtopic).

And in $FTP/www/forum/ you would just have to generate a regular .htaccess meant to be used in the domain's (so here it's the sud domain's) root, $FTP/www/forum/ that is.

Basically, you need the exact same .htaccess in both directories, except that you'll have to add forum/ in front of the rewriterules script names (right part) in the $FTP/www/ one.

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

Re: Help on URL Rewrite

Postby anandharaj » Sat Jul 11, 2009 2:05 pm

Hi,

Based on your sample, the final URL will be -www.tamilminnal.net/forum/xxxxx right?

What i have in mind, based on certain page (viewforum.php, viewtopic.php) - simply change the domain from -www.tamilminnal.net to forum.tamilminnal.net

This mean, if user access -www.tamilminnal.net/viewtopic.php?f=1&t=2 it should become forum.tamilminnal.net/viewtopic.php?f=1&t=2 and finally the .htaccess in sub-domain will re-write again to clean URL.
anandharaj
 
Posts: 26
Joined: Sat Jul 04, 2009 2:42 pm

Re: Help on URL Rewrite

Postby dcz » Sat Jul 11, 2009 2:14 pm

anandharaj wrote:Based on your sample, the final URL will be -www.tamilminnal.net/forum/xxxxx right?


ho, damned, the zero dupe will not handle this case.

So just use the full redirect way :
Code: Select all
RewriteRule ^forum\.html$ http://www.example.com/index.php [QSA,L,NC,R=301]


will work, and it's the only way to have your url redirected on a per case basis, eg, let you use the main domain for something else.

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


Return to phpBB mod Rewrite

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 11 guests


 
cron