SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Feb 2013
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    htaccess for vbulletin forum installed in subdirectory?

    I have a vbulletin site installed and setup on my server in a subdirectory. I am having issues with having the correct htaccess to route the domain to that subdirectory. I have it working right now and was told this way isnt the best way (but its working). I have several vbulletin sites setup and for some reason this one is giving me problems.

    Code:
    <Files .htaccess>
    order allow,deny
    deny from all
    </Files>
    
    RedirectMatch permanent ^/$ http://motonews.com/forum
    The sites settings on the admin have the site URL and homepage URL both set to http://www.example.com/forum. I was told to try this htaccess that it would be better but it wouldnt let people login to the site, or reset passwords or anything for that matter other than view the site.

    Code:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www.motonews.com [NC]
    RewriteRule ^(.*)$ http://motonews.com/$1 [L,R=301]
    RewriteRule ^/?$ "http\:\/\/motonews\.com\/forum" [R=301,L]
    What is the cleanest way to direct www.example.com to the subdirectory? If no htaccess was provided it was just showing a list of directories on my server (which isnt what I want).

    Thanks, Clayton

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,672
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Clayton,

    The simplest way would be to move all your files into the DocumentRoot. Anything else just makes no sense.

    Okay, other options:

    1. Use an index.php file in the DocumentRoot with a link to the forum.

    2. If you're indeed, refusing to use files in the DocumentRoot (except .htaccess), use something like:

    Code:
    RewriteEngine on
    RewriteBase /forum
    
    RewriteCond %{REQUEST_URI} !^/forum
    RewriteRule .? /forum%{REQUEST_URI} [L]
    As for your code:

    Code:
    RedirectMatch permanent ^/$ http://motonews.com/forum
    Then

    Code:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www.motonews.com [NC]
    RewriteRule ^(.*)$ http://motonews.com/$1 [L,R=301]
    RewriteRule ^/?$ "http\:\/\/motonews\.com\/forum" [R=301,L]
    • I dislike using the RewriteBase directory because it can adversely affect redirections.
    • You failed to escape the dot characters in your regex tup: though for the No Case flag)
    • Capturing the {REQUEST_URI} with the EVERYTHING atom is a waste of server resources
    • Your regex states that you do not know whether you're using an Apache 1.x or Apache 2.x server but you want only the domain to have been requested. Clearly, that's NOT what you want. Then you've quoted and escaped EVERYTHING in the redirection (when quotes and escapes are never used); how silly is that?


    You might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It's helped may members and should help you, too.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Member
    Join Date
    Feb 2013
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I will put the files in root. I just wish i really knew all this wizardry when it comes to apache and htaccess.

    Thanks for the help, and suggestions!


Bookmarks

Posting Permissions

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