PDA

View Full Version : apache & mod_rewrite problems


kingkunt
28th December 2005, 23:09
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?
<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]
here is a sample of the .htaccess file controling the urls.
thanks in advance

till
28th December 2005, 23:20
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:

<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.

falko
28th December 2005, 23:24
What's in the Apache logs (access.log and error.log) when you try to access http://site.com/register ?

kingkunt
29th December 2005, 01:27
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,
/home/www/web1/web/test/.htaccess: Options not allowed here
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
File does not exist: /home/www/web1/web/test/news, referer: http://site.com/test/

till
29th December 2005, 10:26
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.

falko
29th December 2005, 11:35
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?

kingkunt
2nd January 2006, 21:24
i set the httpd.conf files .htaccess settings to allowoveride all and i still get a 500 internal server error?


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
# 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:

till
2nd January 2006, 22:34
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 />"

mspIggy
9th July 2008, 05:29
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

mspIggy
9th July 2008, 07:36
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