Forum Moderators: phranque
I'm using a cpanel called webmin and virtualmin on a debian server. After setting up a new virtual server and trying to install wordpress I noticed that htaccess files dont work. They actually disappear from the server side of my ftp window. The cpanel file explorer does see it, but the file does not work.
Here's what I did to try and make it work. There must be an error somewhere in here. Can you point it out?
Document Options for Files /home/[username]/public_html/.htaccess
Directory options - Selected below - set all to yes
Options file can override - Selected below - set all to yes
Suggestions anyone?
This is either a setting worded like "Show system files" or it may be a setting called something like "Set directory command." If this latter, then you typically set it to "ls -al" to show all files.
If your .htaccess file does not work, then look at your server error log file to find out why the server doesn't like it -- The error messages are often quite specific.
Jim
Options +FollowSymLinks -MultiViews
As I said above:
"If your .htaccess file does not work, then look at your server error log file to find out why the server doesn't like it -- The error messages are often quite specific."
Jim
The error log says the following:
[Tue Dec 25 17:16:44 2007] [error] [client [ipaddress] File does not exist: /home/[username]/public_html/hallo-wereld
This is off course because the htaccess file is not working.
I changed the contents of the file to:
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /index.php [L]
</IfModule>
But it didnt work either.
Could it be a user rights problem? After login in with my ftp program Im also not able to chmod.
So there is no logged error relating to mod_rewrite being missing or disabled. That's good -- it means that it's likely to be a path-related problem, and you may need to adjust RewriteBase.
Look at the path in the error line above, and verify that it is correct (except for the final "hallo-wereld" part which you expect to rewrite). The rest of the path should agree with the "DocumentRoot" setting of the server. If not, then you'll need to use RewriteBase to add the extra path info.
In other words, your code will only work if the filepath to .htaccess is exactly "/home/[username]/public_html/.htaccess"
One thing you can do as a test is to modify your code (temporarily) to 'expose' the variables that your code depends on by doing an external redirect:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^my-test-URL\.html$
RewriteRule .* http://www.example.com/my-test-URL.html?Doc_Root=%{DOCUMENT_ROOT}&Req_Fname=%{REQUEST_FILENAME} [R=301,L]
Jim
mv /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/
Then I set the rights for the .htaccess file in the document options. Directory options set to 'selected below' 'Set for directory' all to yes. Then 'Options file can override' set to 'selected below' and then I saved.
Last thing I did have to do was chmod the .htaccess file so wordpress could write to it. And now mod rewrite works!
I hope this will be of help to others. It was really stressing me out.
Thanks for your input and help.