Simple redirect question

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

Moderator: Moderators

Simple redirect question

Postby Pottsy » Thu Aug 31, 2006 3:45 pm

I have the advanced rewrite and the sitemaps mod on my site, www.civinfo.com

BUT, my site is actually a subdomain, it's www.civinfo.colonyrpg.com. I'd like to redirect any request on www.civinfo.colonyrpg.com to www.civinfo.com - how do I do it?

Sorry for being a bit of a newbie with this :oops:

My htaccess looks like:
Code: Select all
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^civinfo\.com$ [NC]
RewriteRule ^(.*) http://www.civinfo.com/$1 [QSA,L,R=301]
RewriteBase /

#########################################################
# forum SEO REWRITE RULES            #
#########################################################
# AUTHOR : DCZ http://www.forum-seo.com/
# STARTED : 01/2006
#####################################################
# FORUMS PAGES
########################
# FORUM PROTECTION RULE
RewriteRule ^forum/.+/([^/]+\.html)$ /forum/index.php [R=301,L]
# CATEGORIES
RewriteRule ^forum/.+-vc([0-9]+)\.html$ /forum/index.php?c=$1 [QSA,L]
# PAGINATED FORUM
RewriteRule ^forum/.+-vf([0-9]+)-([0-9]+)\.html$ /forum/viewforum.php?f=$1&start=$2 [QSA,L]
# FORUM
RewriteRule ^forum/.+-vf([0-9]+)\.html$ /forum/viewforum.php?f=$1 [QSA,L]
# PAGINATED TOPIC
RewriteRule ^forum/.+-vt([0-9]+)-([0-9]+)\.html$ /forum/viewtopic.php?t=$1&start=$2 [QSA,L]
# TOPIC
RewriteRule ^forum/.+-vt([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 forum PAGES
#####################################################

#########################################################
# MX GG_SITEMAPS REWRITE RULES            #
#########################################################
# AUTHOR : dcz http://www.phpbb-seo.com/
# STARTED : 2006/02/22
########################



########################################################
# phpBB
RewriteRule ^sitemaps.xml$ /sitemap.php [L]
RewriteRule ^forum-sitemap-([0-9]+).xml$ /sitemap.php?fid=$1 [L]
RewriteRule ^sitemap-forum.xml$ /sitemap.php?forum [L]
# mxBB
RewriteRule ^mx-sitemap.xml$ /sitemap.php?mx [L]
# KB
RewriteRule ^kb-sitemap-([0-9]+).xml$ /sitemap.php?kbid=$1 [L]
RewriteRule ^sitemap-kbcat.xml$ /sitemap.php?kbcat [L]

#########################################################
# END GG_SITEMAPS REWRITE RULES            #
#########################################################

########################################################
RewriteRule ^forum/sitemaps([0-9]+)\.html$ /forum/sitemaps.php?c=$1 [QSA,L]
RewriteRule ^forum/sitemaps\.html$ /forum/sitemaps.php [QSA,L]
RewriteRule ^forum/forum-m\ap\.html$ /forum/sitemaps.php?fim [QSA,L]
RewriteRule ^forum/forum-m\ap([0-9]+)-([0-9]+)\.html$ /forum/sitemaps.php?fmp=$1&start=$2 [QSA,L]
RewriteRule ^forum/forum-m\ap([0-9]+)\.html$ /forum/sitemaps.php?fmp=$1 [QSA,L]
#########################################################
# END SITEMAPS REWRITE RULES            #
#########################################################

Pottsy
 
Posts: 8
Joined: Thu Aug 03, 2006 3:03 pm

Advertisement

Postby dcz » Thu Aug 31, 2006 10:58 pm

So everything is working great with your .htaccess except the www prefix redirection : http://civinfo.com/ works well, but the rewriterule seems to be tricked in your case by the sub-domain starting with the same "civinfo".

So please try :

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


Instead of :


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


This way should work for all cases. At least if your sub-domain is leading to the same exact folder as the main domain does.
You could have two phpBB scripts running on the same db after all ;)

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

Postby Pottsy » Fri Sep 01, 2006 3:28 pm

dcz,

I'm sorry, I didn't explain well enough!

I just need to 301 redirect any request to www.civinfo.colonyrpg.com to www.civinfo.com.
Pottsy
 
Posts: 8
Joined: Thu Aug 03, 2006 3:03 pm

Postby dcz » Sat Sep 02, 2006 9:38 am

Well, unless, as I told you, you are running two separate instances of phpBB sharing the same DB on those two domains, which I doubt, what I suggested is even doing better than just redirecting on to the other.

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


Makes sure that only www.civinfo.com will be used as a domain, all other domains leading here will be http 301 redirected, thus the one you want.

If it's not working, it's either that, as said in the www prefix topic, you need to play around the rule to make it work for you particular server settings, or that you really have to instance of phpBB running. If so you'd just need to either set your dns to have you old sub domain leading to your new one, or to simply add this www prefix redirection in both ftp account.

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

Postby Pottsy » Sat Sep 02, 2006 12:31 pm

dc,

Once again you have come to my rescue. All working, thank you!
Pottsy
 
Posts: 8
Joined: Thu Aug 03, 2006 3:03 pm

Postby dcz » Sat Sep 02, 2006 11:26 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: 21394
Joined: Fri Apr 28, 2006 9:03 pm


Return to Apache mod Rewrite

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 2 guests


 
cron