MOd_rewrite woes

Discussion in 'Apache' started by shabda, Aug 18, 2007.

  1. #1
    I want to set up mod_rewrite to work with apache. So I installed apache on my box. Since these days apache comes with mod_rewrite installed by default, I thought I would not have to make any changes to apache to get it working, but for some reason mod_rewrite is not working.
    My apache version is "Apache version 2.0.59"
    1. I have the following lines present my httpd.conf
    
    LoadModule rewrite_module modules/mod_rewrite.so
    
    Code (markup):
    2. modules/mod_rewrite.so is available on my system.
    3. To test mod rewrite I created a .htacces file under /var/www/html/test/
    with the following lines
    
    RewriteEngine On
    RewriteRule ^check\.php$ /phpinfo.php [L]
    
    Code (markup):
    I have the file /var/www/html/phpinfo.php present. Now trying to access the page at www.shabda.name/test/check.php gives a 404 error while www.shabda.name/phpinfo.php gets me the required page.
    So mod_rewrite is not working.

    Hrrmff!
     
    shabda, Aug 18, 2007 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^test/check\.php$ phpinfo.php [L]

    domain.com/.htaccess

    http://www.shabda.name/test/phpinfo.php
    is dead there for it can't work since you have .htaccess stuck in the test directory and that file isn't in that directory.
     
    Nintendo, Aug 18, 2007 IP
  3. shabda

    shabda Peon

    Messages:
    348
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi Nintendo.
    Thanks a ton for trying to help me.
    I modified my /var/www/html/.htaccess file to the one you recommended. I created a new file so that http://www.shabda.name/test/phpinfo.php is accesible. But even then I cant get mod_reqrite to work.
    Any way this is not the rule I want to write. I am trying to set up WPMU and that has a given .htaccess file. So I am pretty sure that rules files is correct. My guess is that for some reason mod_rewrite is not being picked up by apache. Do we need to do anythin apart from the lines
    LoadModule rewrite_module modules/mod_rewrite.so to enable mod_rewrite?
     
    shabda, Aug 18, 2007 IP
  4. shabda

    shabda Peon

    Messages:
    348
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #4
    My problem is solved. The problem was that in my httpd.conf
    I had made the changes

    
    <Directory />
        Options FollowSymLinks Indexes
        AllowOverride  FileInfo Options
    </Directory>
    
    Code (markup):
    But later in the httpd.conf I had given the configuration option as
    
    <directory "/var/www/html">
    ....
    AllowOverride None
    
    Code (markup):
    Changed to allowoverride all, and its all working.
     
    shabda, Aug 18, 2007 IP
  5. Diablos

    Diablos Guest

    Messages:
    563
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hey guys,

    I'll post on here so I don't have to create a seperate thread :)
    I also have a problem, a client I am working for has his domain hosted externally and is using the cpannel x stuff to moderate it. I have FTP access but not to the actual server.

    I understand that I can use mod_rewrite through the .htaccess file (which I can access) but I am not wanting to "neaten" a URL but to redirect anyone linking to/typing in caps in the path of the URL

    i.e

    mydomain.com/PaGe1.html

    to be rewritten to

    mydomain.com/page1.html

    Obviously it's on apache and the case issue is casuing us some errors. Any help would be nice I am a bit n00b at this coding stuff.
     
    Diablos, Aug 21, 2007 IP
  6. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #6
    CheckSpelling on
     
    Nintendo, Aug 21, 2007 IP
  7. Diablos

    Diablos Guest

    Messages:
    563
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Is that the line I need in my htaccess Nintendo?
    Thanks BTW

    Hmm i looked into it a little more and tried adding the line but it creates a 500 error, is it possible it's not installed on the server (remembering I don't have te actual server only the crappy control panel thing)

    [edit] OK I have tried a few things I have read up on and neither seem to work.

    Placing just "CheckSpelling on" gives my whole site a 500

    Using

    <IfModule mod_speling.c>
    CheckSpelling On
    </IfModule>

    results in all mispellings/case errors to remain as 404 and go to my (custom) 404 page



    What am I missing to activate the function correctly?
     
    Diablos, Aug 22, 2007 IP
  8. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #8
    Nintendo, Aug 22, 2007 IP
  9. Diablos

    Diablos Guest

    Messages:
    563
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Yeah thats exactly what I wanted, hmmm thanks for the help anyway Nintendo, I am sure its something stupid server side.
     
    Diablos, Aug 23, 2007 IP