LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 01-21-2012, 08:05 PM   #1
zulubanshee
LQ Newbie
 
Registered: Jan 2012
Posts: 7

Rep: Reputation: Disabled
apache not reading htacesss files


I hope this is the right forum.

I was developing on Windows with Wampserver, and I just installed Linux through Virtualbox and with Apache. I ported a site to apache but it's not reading the .htaccess file. I know mod_rewrite is installed, (I've checked)and I've done everything I can think I've found on the various forums and blogs but I'm stuck.


I made sure the the apache2.conf file has AccessFileName .htaccess
I Made sure the AllowOverride directive in /etc/apache2/sites-available/default says "All"
Code:
<Directory /var/www/>
		Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 allow from all
</Directory>
phpinfo says mod_rewrite is enabled
a2enmed rewrite says mod_rewrite is enabled.

I've been on this for like 3 days.

Would anyone have any suggestions
 
Old 01-22-2012, 01:11 AM   #2
vishnu_sreekumar
Member
 
Registered: Jan 2006
Location: India
Distribution: Ubuntu, RHEL, Debian
Posts: 47

Rep: Reputation: 20
What about the permissions of the file .htaccess? Can the user under which apache process is running (generally www-data or apache or nobody) have read access?
 
Old 01-22-2012, 01:42 AM   #3
John VV
Guru
 
Registered: Aug 2005
Location: Ann Arbor Mi.
Distribution: OpenSUSE 12.1 & Scientfic Linux 6.1
Posts: 7,298

Rep: Reputation: 706Reputation: 706Reputation: 706Reputation: 706Reputation: 706Reputation: 706Reputation: 706
if you have root access to the server ( and you do ) there is really no need for a .htaccess file
set the properties for that folder in the httpd.conf

now if you are setting it up for a third person to login and use that folder for THERE web site and not yours then a .htaccess would be needed for THEM to set settings in that folder that they do NOT not have root access to.


also this is on "Virtualbox" so it might be a Virtualbox issue
IS Virtualbox set up correctly for hosting a virtual web server on a virtual linux install on Windows .
 
Old 01-22-2012, 04:57 AM   #4
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu
Posts: 1,199

Rep: Reputation: 76
The directory tag should point exactly at your site's document root:
<Directory /var/www/>
Is this the site's docroot?
 
Old 01-22-2012, 03:00 PM   #5
zulubanshee
LQ Newbie
 
Registered: Jan 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by j-ray View Post
The directory tag should point exactly at your site's document root:
<Directory /var/www/>
Is this the site's docroot?
yes it is. The front page of all the sites are loading, but when i click on a link that requires mod_rewrite to make the pretty urls, I get the Not Found page.
 
Old 01-22-2012, 03:29 PM   #6
zulubanshee
LQ Newbie
 
Registered: Jan 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by John VV View Post
if you have root access to the server ( and you do ) there is really no need for a .htaccess file
set the properties for that folder in the httpd.conf

now if you are setting it up for a third person to login and use that folder for THERE web site and not yours then a .htaccess would be needed for THEM to set settings in that folder that they do NOT not have root access to.


also this is on "Virtualbox" so it might be a Virtualbox issue
IS Virtualbox set up correctly for hosting a virtual web server on a virtual linux install on Windows .


The server is for development purposes only. I don't really understand the part about there being no need for a .htaccess file. I have more than one site in my www directory, each site has a different htaccess file.
 
Old 01-22-2012, 03:44 PM   #7
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu
Posts: 1,199

Rep: Reputation: 76
But if every site has its own .htaccess then they reside in separate folders, don't they? You have to set the allowOverride for each of these directories, I guess.

Last edited by j-ray; 01-22-2012 at 03:46 PM.
 
Old 01-22-2012, 04:09 PM   #8
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,609

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
The easiest way to check if apache reads .htaccess files is to put some gibberish in it.
You should get a 500 error if you visit the directory where this .htaccess is located.
 
Old 01-22-2012, 04:10 PM   #9
zulubanshee
LQ Newbie
 
Registered: Jan 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by j-ray View Post
But if every site has its own .htaccess then they reside in separate folders, don't they? You have to set the allowOverride for each of these directories, I guess.
I did do that, this is what I have.

Code:
<VirtualHost *:80>
	ServerAdmin webmaster@localhost
	DocumentRoot /var/www

<Directory />
	Options FollowSymLinks
	AllowOverride All
 </Directory>

<Directory /var/www/>
	Options Indexes FollowSymLinks MultiViews
	AllowOverride None
	Order allow,deny
	allow from all
</Directory>

#added by me start
<Directory /var/www/bookstore3/>
	Options Indexes FollowSymLinks MultiViews
	AllowOverride All
	Order allow,deny
	allow from all
</Directory>
#added by me end


	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
	<Directory "/usr/lib/cgi-bin">
		AllowOverride None
		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
		Order allow,deny
		Allow from all
	</Directory>

	ErrorLog ${APACHE_LOG_DIR}/error.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn

	CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>
 
Old 01-22-2012, 04:20 PM   #10
zulubanshee
LQ Newbie
 
Registered: Jan 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by bathory View Post
The easiest way to check if apache reads .htaccess files is to put some gibberish in it.
You should get a 500 error if you visit the directory where this .htaccess is located.
I did that and that is exactly what happens.

This seems like it should be simple and I cant figure out why its not. I know the instructions in the htaccess file are correct because I ported them from another server.
 
Old 01-22-2012, 04:37 PM   #11
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,609

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
Mind that .htaccess will work only for those directories where you have "AllowOverride All". So in based on your config above, it's not going to work for Directory /var/www, /usr/share/doc.
If this is not the case, then, most likely the RewriteCond directive/s is/are not met.
You could post the rewrite stuff , so we could take a look.
 
Old 01-22-2012, 05:35 PM   #12
zulubanshee
LQ Newbie
 
Registered: Jan 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by bathory View Post
Mind that .htaccess will work only for those directories where you have "AllowOverride All". So in based on your config above, it's not going to work for Directory /var/www, /usr/share/doc.
If this is not the case, then, most likely the RewriteCond directive/s is/are not met.
You could post the rewrite stuff , so we could take a look.
I tried AllowOverride All but it broke the whole site
Here is what is in my htaccess file
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
 
Old 01-23-2012, 02:39 AM   #13
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,609

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
Hi,

Your rewrite looks good, so indeed the situation is strange. If you've copied .htaccess from the windows server, make sure there are no non-printable or special characters in it.
You can also delete the .htaccess and put its contents inside the VirtualHost stanza and see what happens. In this case you can also enable logging, by adding:
Code:
RewriteLogLevel 9
RewriteLog logs/rewrite_log
and see if you get anything.

Regards
 
Old 01-23-2012, 09:08 PM   #14
zulubanshee
LQ Newbie
 
Registered: Jan 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by bathory View Post
Hi,

You can also delete the .htaccess and put its contents inside the VirtualHost stanza and see what happens. In this case you can also enable logging, by adding:
Code:
RewriteLogLevel 9
RewriteLog logs/rewrite_log
and see if you get anything.

Regards
Well thanks a lot that worked! I did the second part a couple of days ago (put the code in the virtual host file), but did not delete the .htaccess file from the individual folders.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Apache not reading .htacces on 443 MasterMatt Linux - Newbie 4 05-05-2011 02:30 AM
problem in mounting cdrom(audio files running but not reading data files) amit_usual Linux - Newbie 7 12-29-2007 05:52 AM
reading apache log files fiona333 Linux - Newbie 1 06-28-2007 01:11 PM
Apache not reading .htaccess files jmoschetti45 Linux - Server 5 03-18-2007 09:35 AM
reading /home/$USER_HOMEDIR/ with apache sizzlingdesi Linux - Software 1 11-22-2006 12:47 PM


All times are GMT -5. The time now is 07:57 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration