Resolved htaccess cannot get to work! OS X Lion

Discussion in 'Mac OS X Server, Xserve, and Networking' started by crittle1, Feb 4, 2014.

  1. crittle1, Feb 4, 2014
    Last edited: Feb 8, 2014

    crittle1 macrumors newbie

    Joined:
    Feb 4, 2014
    #1
    I've enabled mod_rewrite.so in httpd.conf

    I've updated the apache2/httpd.conf to reflect

    DocumentRoot "/Library/WebServer/Documents"

    Code:
    <Directory />
         Options Indexes MultiViews FollowSymLinks
         AllowOverride All
         Order deny, allow
         Deny from all
    </Directory>
    
    <Directory "/Library/WebServer/Documents">
         Options Indexes FollowSymLinks MultiViews
         AllowOverride All
         Order allow, deny
         Allow from all
    </Directory>


    I've changed apache2 / users / [username].conf
    ( Just a shot in the dark. I also tried /Users/[username]/Sites/ )


    Code:
    <Directory "/Library/WebServer/Documents">
         Options Indexes MultiViews FolowSymlinks
         AllowOverride All
         Order allow, deny
         Allow from all
    </Directory>


    I've even aded AccessFilename .htaccess to the httpd.conf file just incase.


    I've ticked the "Allow overrides using .htaccess files" In the Server advanced configuration for the website.


    htaccess file
    (I am just trying a very simple change in the .htaccess to sample if the .htaccess is working. )

    Code:
    DirectoryIndex test.html

    I've been messing around with this for 2 days now and cannot find an answer.


    I really need this to work


    Thanks in advance.
     
  2. AmestrisXServe macrumors 6502

    Joined:
    Feb 6, 2014
    #2
    I'm running Leopard, but this is my access configuration for htaccess:
    (Note: I am only including the relevant lines here.)

    httpd.conf


    Group www
    ##
    ## Each directory to which Apache has access, can be configured with respect
    ## to which services and features are allowed and/or disabled in that
    ## directory (and its subdirectories).
    ##
    ## First, we configure the "default" to be a very restrictive set of
    ## features.
    ##
    <Directory "/">
    Options FollowSymLinks
    AllowOverride All
    </Directory>

    #### For Mac OS X Server: Uncomment this line to enable web-based
    #### configuration of mailman:
    ##
    # Include /etc/apache2/httpd_mailman.conf
    <IfModule mod_setenvif.c>
    <IfModule mod_negotiation.c>
    # Allow convenient access to Apache manual
    AliasMatch ^/manual(?:/(?:de|en|es|fr|ja|ko|pt-br|ru))?(/.*)?$ "/Library/WebServer/share/httpd/manual$1"
    <Directory "/Library/WebServer/share/httpd/manual">
    Options Indexes
    AllowOverride All
    Order allow,deny
    Allow from all
    <Files *.html>
    SetHandler type-map
    </Files>
    SetEnvIf Request_URI ^/manual/(de|en|es|fr|ja|ko|pt-br|ru)/ prefer-language=$1
    RedirectMatch 301 ^/manual(?:/(de|en|es|fr|ja|ko|pt-br|ru)){2,}(/.*)?$ /manual/$1$2
    LanguagePriority en de es fr ja ko pt-br ru ForceLanguagePriority Prefer Fallback
    </Directory>
    </IfModule>
    </IfModule>
    </IfModule>

    <Directory "/usr/share/httpd/error">
    AllowOverride All
    Options IncludesNoExec
    AddOutputFilter Includes html
    AddHandler type-map var
    Order allow,deny
    Allow from all
    LanguagePriority en cs de es fr it ja ko nl pl pt-br ro sv tr
    ForceLanguagePriority Prefer Fallback
    </Directory>



    I think that you need to change your permissions order from deny,allow to allow,deny.

    Setting deny,allow seems to cause certain problems.

    I also modified each user individually:

    user.conf

    <Directory "/Users/username/Sites/">
    Options +Indexes MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>


    This allows me to use realms to control site access, and setting AllowOverride All on each user forces .htaccess to work, where it may not elsewhere.

    Finally, here is a generic htaccess file that I use to force logins using the local user accounts and passwords files, and to auto-create indexes of directories:

    AuthName "Sitename"
    AuthType Basic
    AuthUserFile /Users/.htpasswd
    AuthGroupFile /dev/null
    require valid-user
    Options +Indexes


    Mind you, this is on 10.5.8. I've never used Lion, but it may be a similar carry over problem from Apple's older apache2 configs.

    I think that I had to edit my 0000_any_xx config files as well:

    <Directory "/Users/Amestris/Sites/magesguild">
    AllowOverride All
    <IfModule mod_dav.c>
    DAV Off
    </IfModule>
    Options All -Includes -ExecCGI +MultiViews +Indexes
    </Directory>


    I hope you can get your htaccess working using some of this...
     
  3. crittle1 thread starter macrumors newbie

    Joined:
    Feb 4, 2014
    #3
    Bless you!

    I am going to compare and adjust.

    Besides that, you know what the issue was? Text edit was appending a .txt at the end. Now it wasn't blatant... but was hidden. So the .htaccess was greyed out like a hidden file, but when I right clicked and chose "Get Info" I could see the .txt on the end from the get info box. Really?? Removed it in the Get Info, bam, started working. What a waste of a day. At least that's solved.
     
  4. AmestrisXServe macrumors 6502

    Joined:
    Feb 6, 2014
    #4
    I tend to use pico or nano (in a shell), or Coda in GUI. For something like an .htaccess file, pico or nano work better than textedit, as the filename at write-out is always exactly what you specify.

    Coda is the most wonderful programme for server stuff that you can ever buy. :)

    I would also suggest enabling showing hidden files inthe finder. DO this by entering this command in a shell:

    defaults write com.apple.finder AppleShowAllFiles TRUE

    You can also view them in a shell with ls -lr .

    Good to know that the Leopard apache2 stuff still works with Lion. I don't know why Apple haven't ever fixed this problem, but that 'Allow All Overrides' checkbox in Server Admin has always been broken, as it doesn't actually change the apache2 config files.

    To be frank, Apple have made some odd choices with the default apache2 configurations,and I have always had to modify the files.

    You always need to do that manually, and then tick that checkbox.

    If you don't want autoindexing, remove +Indexes from the htaccess files. I enabled it to allow directory browsing on certainsites. (It's yet another thing that is disabled by default.) You may not want raw directory listing on.

    You may also want to put a robots.txt file in any directory that you don't want google, et.al., to capture.

    Best of luck in any further configration. :)
     
  5. billkenney macrumors newbie

    Joined:
    Jan 5, 2015
    #5
    After attempting to fix this problem for 6 hours I was finally able to get this to work. I edited the httpd.conf, httpd-userdir.conf, httpd-vhosts.conf, etc to no avail. Leaving all of these files unedited from the yosemite configuration, what finally worked for me was to edit the httpd_server_app.conf located at /Library/Server/Web/Config/apache2/ by adding the following (for each site) as follows:

    Code:
    <Directory />
        Options +FollowSymLinks
        AllowOverride All
        Order deny,allow
        Deny from all
    </Directory>
    
    <Directory "/Library/Server/Web/Data/Sites/Default/">
        Options +Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    
    <Directory "/Library/Server/Web/Data/Sites/[OTHER SITE DIRECTORY]/">
        Options +Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    Make sure if you use textedit to edit this file you undo the automatic insertion of the slanted quotation marks otherwise you will get a unicode error message.

    Hope this helps!
     

Share This Page