apache & mod_rewrite problems

Discussion in 'Server Operation' started by kingkunt, Dec 28, 2005.

  1. kingkunt

    kingkunt New Member

    Hi im running suse9.3 perfect setup
    my problem is when a script is installed its using .htaccess files to control the virtual urls,
    ie: http://site.com/register
    not http://site.com/register.php
    my apache installation shows mod_rewrite in the phpinfo but the urls are not working?
    Does anyone have any idea how i can possibly find out what the problem is?
    here is a sample of the .htaccess file controling the urls.
    thanks in advance
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Does your .htaccess file contains this line:

    RewriteEngine On

    to enable the rewrite engine before the part with the rewrite rules?

    At the end of your httpd.conf is a section which limits the permissions for htaccess files:

    Code:
    <Directory /home/www/*/web>
        Options +Includes +FollowSymlinks -Indexes
        AllowOverride Indexes AuthConfig Limit FileInfo
        Order allow,deny
        Allow from all
    
        <Files ~ "^\.ht">
        Deny from all
        </Files>
    </Directory>
    Maybe you must extend the allow override settings or set it even to:

    AllowOverride All

    But be aware that this is an security risk if you host websites for customers on your server.
     
    Last edited: Dec 28, 2005
  3. falko

    falko Super Moderator ISPConfig Developer

  4. kingkunt

    kingkunt New Member

    RewriteEngine On is at the top of the .htaccess
    I checked the error.log and i this is the error displayed when i view the pages,
    with the .htaccess file in place i get 500 internal server error.
    When i remove it i can see the pages but all links are missing the .php extension.
    heres the error log for when i click the link with no .php extension
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Have you set "AllowOverride All" in your httpd.conf (can also be named apache.conf or apache2.conf depending on your linux distribution) as i described above? It should fix your .htaccess problem. Dont forget to restart your apache server after the change of httpd.conf.
     
  6. falko

    falko Super Moderator ISPConfig Developer

    Normally rewrite rules should work in an ISPConfig web site ( http://www.howtoforge.com/forums/showthread.php?t=38 ).
    I guess one of the other directives is causing problems. Can you remove anything but what is related to mod_rewrite from the .htaccess file and try again?
     
  7. kingkunt

    kingkunt New Member

    i set the httpd.conf files .htaccess settings to allowoveride all and i still get a 500 internal server error?

    Code:
    Options +FollowSymlinks
    RewriteEngine On
    
    AddType text/xml .xslt
    
    <Files *.xslt>
    	SetHandler text/xml
    </Files>
    
    <IfModule !mod_php4.c>
    
    	<IfModule !mod_php5.c>
    
    		# PHP is in CGI Mode, so we need a different mod_rewrite
    
    		RewriteCond %{REQUEST_URI} !categories\.php
    		RewriteRule ^categories(.*) categories.php?$1 [L]
    		
    		RewriteCond %{REQUEST_URI} !articles\.php
    		RewriteRule ^articles(.*)$ articles.php?$1 [L]
    		
    		RewriteCond %{REQUEST_URI} !pages\.php
    		RewriteRule ^pages(.*)$ pages.php?$1 [L]
    		
    		RewriteCond %{REQUEST_URI} !blogs\.php
    		RewriteRule ^blogs(.*)$ blogs.php?$1 [L]
    		
    		RewriteCond %{REQUEST_URI} !search.php
    		RewriteRule ^search(.*)$ search\.php?$1 [L]
    		
    		RewriteCond %{REQUEST_URI} !authors.php
    		RewriteRule ^authors(.*)$ authors\.php?$1 [L]
    		
    		RewriteCond %{REQUEST_URI} !articlerss.php
    		RewriteRule ^articlerss(.*)$ articlerss\.php?$1 [L]
    		
    		RewriteCond %{REQUEST_URI} !news.php
    		RewriteCond %{REQUEST_URI} !newsrss.php
    		RewriteRule ^news(.*)$ news.php?$1 [L]
    		
    		RewriteCond %{REQUEST_URI} !contact.php
    		RewriteRule ^contact(.*)$ contact\.php?$1 [L]
    		
    
    	</IfModule>
    
    	<IfModule mod_php5.c>
    		
    		# Using PHP 5 in module mode
    
    		RewriteCond %{REQUEST_URI} categories.*
    		RewriteRule ^categories(.*)$ categories.php?$1 [T=application/x-httpd-php,L]
    
    		RewriteCond %{REQUEST_URI} articles.*
    		RewriteRule ^articles(.*)$ articles.php?$1 [T=application/x-httpd-php,L]
    
    		RewriteCond %{REQUEST_URI} pages.*
    		RewriteRule ^pages(.*)$ pages.php?$1 [T=application/x-httpd-php,L]
    
    		RewriteCond %{REQUEST_URI} blogs.*
    		RewriteRule ^blogs(.*)$ blogs.php?$1 [T=application/x-httpd-php,L]
    
    		RewriteCond %{REQUEST_URI} search.*
    		RewriteRule ^search(.*)$ search.php?$1 [T=application/x-httpd-php,L]
    
    		RewriteCond %{REQUEST_URI} authors.*
    		RewriteRule ^authors(.*)$ authors.php?$1 [T=application/x-httpd-php,L]
    
    		RewriteCond %{REQUEST_URI} articlerss.*
    		RewriteRule ^articlerss(.*)$ articlerss.php?$1 [T=application/x-httpd-php,L]
    
    		RewriteCond %{REQUEST_URI} news.*
    		RewriteCond %{REQUEST_URI} !newsrss
    		RewriteRule ^news(.*)$ news.php?$1 [T=application/x-httpd-php,L]
    		
    		RewriteCond %{REQUEST_URI} contact.*
    		RewriteRule ^contact(.*)$ contact.php?$1 [T=application/x-httpd-php,L]
    
    	</IfModule>
    
    </IfModule>
    
    <IfModule mod_php4.c>
    
    	# PHP 4 in module mode
    
    	RewriteCond %{REQUEST_URI} categories.*
    	RewriteRule ^categories(.*)$ categories.php?$1 [T=application/x-httpd-php,L]
    
    	RewriteCond %{REQUEST_URI} articles.*
    	RewriteRule ^articles(.*)$ articles.php?$1 [T=application/x-httpd-php,L]
    
    	RewriteCond %{REQUEST_URI} pages.*
    	RewriteRule ^pages(.*)$ pages.php?$1 [T=application/x-httpd-php,L]
    
    	RewriteCond %{REQUEST_URI} blogs.*
    	RewriteRule ^blogs(.*)$ blogs.php?$1 [T=application/x-httpd-php,L]
    
    	RewriteCond %{REQUEST_URI} search.*
    	RewriteRule ^search(.*)$ search.php?$1 [T=application/x-httpd-php,L]
    
    	RewriteCond %{REQUEST_URI} authors.*
    	RewriteRule ^authors(.*)$ authors.php?$1 [T=application/x-httpd-php,L]
    
    	RewriteCond %{REQUEST_URI} articlerss.*
    	RewriteRule ^articlerss(.*)$ articlerss.php?$1 [T=application/x-httpd-php,L]
    
    	RewriteCond %{REQUEST_URI} news.*
    	RewriteCond %{REQUEST_URI} !newsrss
    	RewriteRule ^news(.*)$ news.php?$1 [T=application/x-httpd-php,L]
    	
    	RewriteCond %{REQUEST_URI} contact.*
    	RewriteRule ^contact(.*)$ contact.php?$1 [T=application/x-httpd-php,L]
    
    </IfModule>
    here is my httpd.conf
    Code:
    # forbid access to the entire filesystem by default
    <Directory />
        Options +Includes +FollowSymlinks -Indexes
        AllowOverride all
        Order allow,deny
        Allow from all
    </Directory>
    
    # use .htaccess files for overriding,
    AccessFileName .htaccess
    # and never show them
    <Files ~ "^\.ht">
        Deny from all
    </Files>
    ive tried changing and restarting the apache server with no luck?
    :confused:
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    If you use ISPConfig, the code you posted does not affect the ISPConfig websites at all. You must search for this directory directive
    "<Directory /home/www/*/web>" and not for "<Directory />"
     
  9. mspIggy

    mspIggy New Member

    500 internal server error

    i have a fresh install of ISPConfig

    i am having this same problem

    did you solve yours?

    we use several different htaccess files

    every one of them gives me the err

    500 internal server error

    this is mission critial for me...

    i cannot even find the file httpd.conf -- what is the server path to this file?

    in my old server - we enabled htaccess on a persite basis like this >

    <Directory /home/.sites/120/site53/web>
    Options -Indexes
    AllowOverride All
    </Directory>

    is thsi something we can use here?

    where is the httpd.conf file

    thank you
     
  10. mspIggy

    mspIggy New Member

    finally i found this

    .............

    very easy to do!

    many thanks to hans
    ...............................

    Probably .htaccess files are not allowed on your system.
    You can add the following to the Apache directives field of your website:

    <Directory "/var/www/web1/web">
    Options FollowSymLinks
    AllowOverride All
    </Directory>

    Where, web1 is your own webnumber.
    __________________
    Hans
     

Share This Page