Welcome Guest, Not a member yet? Register   Sign In
Removing index.php using .htacess on a virtual host on Apache server/XAMPP
#1

[eluser]aidehua[/eluser]
I've just spent a couple of hours trying to fix this. Finally found the source of the problem, and the solution, so I thought I'd post it here in case it saves someone some time some time.

SCENARIO:
Windows XP / Apache server using XAMPP

I have been using .htaccess to remove index.php from CodeIgniter URLs, as outlined here http://ellislab.com/codeigniter/user-gui.../urls.html and discussed widely in these forums. All worked well.

Today I set up a new virtual host (virtual server) using my httpd-vhosts.conf file, as described in various places on the web, including here: http://www.sawmac.com/xampp/virtualhosts/index.php

I copied-and-pasted this code from the above website:

Code:
NameVirtualHost *
  <VirtualHost *>
    DocumentRoot "C:\xampp\htdocs"
    ServerName localhost
  </VirtualHost>
  <VirtualHost *>
    DocumentRoot "C:\Documents and Settings\Me\My Documents\clientA\website"
    ServerName clientA.local
  <Directory "C:\Documents and Settings\Me\My Documents\clientA\website">
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

Result: I could not use .htaccess to remove index.php from URLs in the new virtual host. It was not that the .htaccess file was working incorrectly: it was not being interpreted at all by the server. (.htaccess files continued to work fine on the original "main" host, "http://localhost")

SOLUTION:

Just insert the following line before the </Directory> tag in httpd-vhosts.conf:
Code:
AllowOverride all

Without this line, .htaccess files are effectively disabled. (This depends on how your httpd.conf file is configured, but the result I got comes from the default XAMPP Windows installation.) Add the line, and .htaccess works as expected.

Problem solved.

(Probably pretty obvious for Apache server pros - but not all of us are... Wink )
#2

[eluser]Colin Williams[/eluser]
I think 50% of the time, this is the problem people have with removing index.php. And it's a bitch to even communicate with them about it. Copy-paste monkeys look at you sideways when you ask them if AllowOverride is on for their directory. So, thanks for sharing this. Might help a few guys and gals out.

And I don't think you need to be a server pro to know this stuff. You just need to stop by the apache docs directives page every now and then.
#3

[eluser]Unknown[/eluser]
Thanks to Grad Student.
It took very long time for me to solving this problem until I see your post.
It worked!
Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB