SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Wizard Goof's Avatar
    Join Date
    Feb 2001
    Location
    Pittsburgh, PA
    Posts
    1,154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    VirtualHost not reading .htaccess??

    Ok, this is weird. I was using separate directories and switching the main HTDOCS folder via MAMP every time I wanted to access a different site locally. Then I realized that I could use subdomains on localhost for multiple dev sites at one time. I setup the /etc/hosts file and the following structure in the Apache config:

    Code:
    <VirtualHost *>
       DocumentRoot "/the/path/to/files"
       ServerName server1.localhost
       AccessFileName .htaccess
       <Directory />
          Options			FollowSymLinks
          AllowOverride		None
       </Directory>
    </VirtualHost>
    It worked! The homepage loads great, until I realized that my mod_rewrites in my .htaccess file weren't working. If I goto server1.localhost/something I get the Apache 404 error, where if I go to server1.localhost/index.php/something I get the proper CodeIgniter (PHP) 404. The .htaccess is the vanilla CodeIgniter file:


    Code:
    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    
    RewriteCond &#37;{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    
    RewriteRule ^(.*)$ /index.php/$1 [L]
    Again, the redirect works fine using the main HTDOCS folder...it's just something with the VirtualHost structure that's goofing it up.

    Any suggestions?

    -Nate

    Edit:


    P.S. I'm assuming that because the VirtualHost is taking place at the Apache level, PHP doesn't know whether it's the main HTDOCS folder, or on a VirtualHost. That's a correct assumption, right? It's not as though something in the complexity of CodeIgniter could be screwing this up, because it doesn't know the difference...?
    Nathan Rutman
    A slightly offbeat creative.

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,650
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by Goof View Post
    Ok, this is weird. I was using separate directories and switching the main HTDOCS folder via MAMP every time I wanted to access a different site locally. Then I realized that I could use subdomains on localhost for multiple dev sites at one time. I setup the /etc/hosts file and the following structure in the Apache config:

    Code:
    <VirtualHost *>
       DocumentRoot "/the/path/to/files"
       ServerName server1.localhost
       AccessFileName .htaccess
       <Directory />
          Options			FollowSymLinks
          AllowOverride		None
       </Directory>
    </VirtualHost>
    It worked! The homepage loads great, until I realized that my mod_rewrites in my .htaccess file weren't working. If I goto server1.localhost/something I get the Apache 404 error, where if I go to server1.localhost/index.php/something I get the proper CodeIgniter (PHP) 404. The .htaccess is the vanilla CodeIgniter file:


    Code:
    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    
    RewriteRule ^(.*)$ /index.php/$1 [L]
    Again, the redirect works fine using the main HTDOCS folder...it's just something with the VirtualHost structure that's goofing it up.

    Any suggestions?

    -Nate

    Edit:


    P.S. I'm assuming that because the VirtualHost is taking place at the Apache level, PHP doesn't know whether it's the main HTDOCS folder, or on a VirtualHost. That's a correct assumption, right? It's not as though something in the complexity of CodeIgniter could be screwing this up, because it doesn't know the difference...?
    You're okay except for the NONE which should be ALL.

    Of course, I'd whine about you using Options +MultiViews as that usually causes major problems (for me).

    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


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
  •