Results 1 to 14 of 14

Moving the .htaccess rewrite rule

This is a discussion on Moving the .htaccess rewrite rule within the General Discussion forums, part of the vBSEO Google/Yahoo Sitemap category; I've had this mod installed for a long time, but I've recently run into a predicament. For various reasons, I ...

  1. #1
    Member
    Real Name
    Nick
    Join Date
    Mar 2009
    Posts
    48
    Liked
    0 times

    Moving the .htaccess rewrite rule

    I've had this mod installed for a long time, but I've recently run into a predicament.

    For various reasons, I need to move the rewrite code to the .htaccess file of my domain's root instead of my /forums directory.

    What can I change the .htaccess rewrite rule to in order for it to work in my root's .htaccess?

    I found this Wiki page of yours: Sitemap:FAQ - VBSEO Wiki
    I want to make sure that by following those steps, my root's sitemap (which is a WordPress blog) will not be overwritten. In other words, I still want my forum sitemap to be located in the same place it currently is, but I just want the rewrite rules to be specified in the root's .htaccess rather than the forum's .htaccess.

    Thanks

  2. #2
    Member
    Real Name
    Nick
    Join Date
    Mar 2009
    Posts
    48
    Liked
    0 times
    Is this even possible to do?

  3. #3
    Senior Member Shadab's Avatar
    Real Name
    Shadab
    Join Date
    Oct 2007
    Location
    Bhopal
    Posts
    821
    Liked
    0 times
    Blog Entries
    12
    Try this rule, for the .htaccess in root:
    Code:
    RewriteRule ^forums/((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ forums/vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
    So the sitemap is still served via this URI : domain.com/forums/sitemap_[...].xml.gz

  4. #4
    Member
    Real Name
    Nick
    Join Date
    Mar 2009
    Posts
    48
    Liked
    0 times
    Quote Originally Posted by Shadab View Post
    Try this rule, for the .htaccess in root:
    Code:
    RewriteRule ^forums/((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ forums/vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
    So the sitemap is still served via this URI : domain.com/forums/sitemap_[...].xml.gz
    Hmm... it's not working.

  5. #5
    vBSEO.com Webmaster Mert Gökçeimam's Avatar
    Real Name
    Lizard King
    Join Date
    Oct 2005
    Location
    Istanbul, Turkey, Turkey
    Posts
    23,100
    Liked
    622 times
    Blog Entries
    4
    You need to use

    Code:
    RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ forums/vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
    Mert Gökçeimam / Crawlability Inc.

    vBSEO 3.6.0 Alpha Önizlemesi - Including Like Tree
    Unveiling the NEW vBSEO Sitemap Generator 3.0 - available NOW for vBSEO Customers!


    Twitter:@Depkac
    Personal Blog : Mert Gökçeimam

  6. #6
    Member
    Real Name
    Nick
    Join Date
    Mar 2009
    Posts
    48
    Liked
    0 times
    Quote Originally Posted by Mert Gökçeimam View Post
    You need to use

    Code:
    RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ forums/vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
    I'm pretty sure I've tried this before and it didn't work... but I'll try again.

  7. #7
    Member
    Real Name
    Nick
    Join Date
    Mar 2009
    Posts
    48
    Liked
    0 times
    Quote Originally Posted by NickR View Post
    I'm pretty sure I've tried this before and it didn't work... but I'll try again.
    Nope, it doesn't work either. :(

    ... I have no idea why.

  8. #8
    Member
    Real Name
    Nick
    Join Date
    Mar 2009
    Posts
    48
    Liked
    0 times
    Perhaps I should explain the reason I need to do this and you could offer a different work-around.

    Basically, I need to re-write all non-WWW visits to anywhere on my site to the WWW version.
    So I have this in my root .htaccess:
    Code:
    RewriteCond %{HTTP_HOST} !^www [NC]
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    It works fine for everything except my /forums directory. I figured out that when I disable the vBSEO rewrite (by adding '#' to the beginning of the line) in my /forums/.htaccess, the WWW rewrite works.
    So obviously, the vBSEO rewrite in the /forums/.htaccess is preventing the WWW rewrite in the root from working on my /forums directory.

    That's why I need to get the vBSEO rewrite out of the /forums/.htaccess and into the root.
    Is there another way around this? Why is the presence of the vBSEO rewrite preventing the WWW rewrite from working?

  9. #9
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,744
    Liked
    168 times
    Hello,

    what is your forums URL?
    So I have this in my root .htaccess:
    It works fine for everything except my /forums directory.
    You can try to add the same rewrite rules in forums/.htaccess as well.

  10. #10
    Member
    Real Name
    Nick
    Join Date
    Mar 2009
    Posts
    48
    Liked
    0 times
    Quote Originally Posted by Oleg Ignatiuk View Post
    Hello,

    what is your forums URL?
    You can try to add the same rewrite rules in forums/.htaccess as well.
    Hi,

    Firstly, thank you for your continued support.

    I have tried to put the WWW rewrite rule in my /forums/.htaccess as well but it tried to redirect non-WWW visitors to this: http://www.lineolatedparakeet.net//h...eet.net/forums

    As you can now see, my URL is Lineolated Parakeet Forum - Linnie Forum Community

  11. #11
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,744
    Liked
    168 times
    Try to change rewrite rules to:
    Code:
    RewriteCond %{HTTP_HOST} !^www [NC]
    RewriteCond %{THE_REQUEST} forums/
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

  12. #12
    Member
    Real Name
    Nick
    Join Date
    Mar 2009
    Posts
    48
    Liked
    0 times
    Quote Originally Posted by Oleg Ignatiuk View Post
    Try to change rewrite rules to:
    Code:
    RewriteCond %{HTTP_HOST} !^www [NC]
    RewriteCond %{THE_REQUEST} forums/
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    I placed that in my /forums/.htaccess file and re-enabled the vBSEO rewrite. I think we're close, but not quite there.

    It redirects http://lineolatedparakeet.net/forums to http://www.lineolatedparakeet.net

  13. #13
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,744
    Liked
    168 times
    Try this:
    Code:
    RewriteCond %{HTTP_HOST} !^www [NC]
    RewriteCond %{THE_REQUEST} forums/
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/forums/$1 [R=301,L]

  14. #14
    Member
    Real Name
    Nick
    Join Date
    Mar 2009
    Posts
    48
    Liked
    0 times
    Quote Originally Posted by Oleg Ignatiuk View Post
    Try this:
    Code:
    RewriteCond %{HTTP_HOST} !^www [NC]
    RewriteCond %{THE_REQUEST} forums/
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/forums/$1 [R=301,L]
    Works like a charm! Thanks

Similar Threads

  1. What is [NF] doing at the end of a rewrite rule ?
    By mihai11 in forum Custom Rewrite Rules
    Replies: 2
    Last Post: 10-27-2008, 03:34 AM
  2. Moving forums to a subdomain, need a redirect rule
    By FightRice in forum General Discussion
    Replies: 1
    Last Post: 09-03-2008, 02:02 PM
  3. Rewrite Rule
    By Floezen in forum Troubleshooting
    Replies: 2
    Last Post: 07-23-2008, 05:59 PM
  4. htaccess rewrite rule for non vbseo page
    By Pat in forum Custom Rewrite Rules
    Replies: 10
    Last Post: 09-19-2006, 02:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •