Results 1 to 4 of 4

Thread: mod_rewrite and .htaccess does not work

  1. #1
    Join Date
    Feb 2009
    Posts
    66

    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

  2. #2
    Join Date
    Apr 2008
    Posts
    193

    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.

  3. #3
    Join Date
    Dec 2008
    Posts
    161

    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.

  4. #4
    Join Date
    Dec 2008
    Posts
    183

    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.

Similar Threads

  1. How to use .htaccess file
    By Antarjot in forum Operating Systems
    Replies: 3
    Last Post: 09-12-2009, 01:40 PM
  2. Problem with .htaccess on Mac OS X
    By austin26 in forum Software Development
    Replies: 3
    Last Post: 03-12-2009, 06:00 PM
  3. What is htaccess? What does it mean in programming language?
    By Aienstaien in forum Software Development
    Replies: 4
    Last Post: 16-09-2009, 02:48 PM
  4. .htaccess and error 403
    By CitricAcid in forum Software Development
    Replies: 4
    Last Post: 27-04-2009, 12:24 PM
  5. .Htaccess problem
    By Jasonholt in forum Software Development
    Replies: 3
    Last Post: 06-04-2009, 09:08 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,393,156.51420 seconds with 16 queries