mod_rewrite and .htaccess does not work
Hello programming gurus
I'm having trouble getting mod_rewrite to work with Apache 2.0 on Ubuntu 9.04. I ran the command "sudo a2enmod rewrite" and it said that the module was installed.
And with the trouble using both trouble mod_rewrite and .htaccess is that When i put the rewrite rules in httpd.conf, they work fine. But when I put them in .htaccess, they don't work.
Thank for your support
Re: mod_rewrite and .htaccess does not work
The code should be added to the .htaccess file in the root directory, but then again I don't think it will actually make a difference; as long as it doesn't conflict with any other rewrite rules in your root directory's .htaccess file. The rule you've referred is needed for clean urls, it can be left alone, in fact none of rules present in drupals main .htaccess file shouldn't cause any problems.
In my case I actually move drupal the site to the root directory, the rewrite rule causes any calls to the subdirectory to be rooted to the root directory, but I believe this should still work in your case.
Re: mod_rewrite and .htaccess does not work
You could add
Options -indexes
and
Directoryindex default.php
near the top of the appropriate .htaccess file(s), in order to tell the server to return "default.php" whenever "/" is requested. See Apache mod_dir and Options in Apache Core documentation for details.
Re: mod_rewrite and .htaccess does not work
Here's a summary of what he said was needed to fix that in the event of nonexistent subdomains needing to be redirected:
1. add a subdomain through cpanel, name it * and point it to the public_html directory.
2. You need to create a * DNS record as well.
3. Each subdomain has it's own VirtualHost block under Apache, so existing ones would be directed where they need to go.
4. Non-existing subdomains would be sent to the main domain and be caught by the .htaccess file. You could then change the line "RewriteCond %{HTTP_HOST} example.com [NC]" to read "RewriteCond %{HTTP_HOST} !" instead.