UbuntuThis forum is for the discussion of Ubuntu Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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.
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?
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 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.
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.
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.
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.
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>
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.
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.
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
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:
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.