Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite on server with linux suse and confixx

mod_rewrite , confiixx, htaceess no work for me

         

jim_knopf

8:52 pm on Dec 4, 2007 (gmt 0)

10+ Year Member



Hi all,

I dont want to put here tons of stuff down not knowing if somebody here is willing to help.

I'm in Mexico / Baja, have a server in Germany (I'm German so that right away as excuse for my @#$&% english) and I'm forced for budget reasons to find solutions myself.....

Hard to get advise in GER with server comapany, service numbers that cost..... I like to make use of mod_rewrite to get them "nice" URL's in Wordpress as well like to deny certain traffic / referer's. I have root access / SSH Explorer and supposedly mod_rewrite is on

Here are my "specs":

Apache/2.0.48 (Linux/SuSE)

PHP Version 4.3.3

Loaded Modules:

core prefork http_core mod_so mod_access mod_actions mod_alias mod_auth mod_auth_dbm mod_autoindex mod_cgi mod_dir mod_env mod_expires mod_include mod_log_config mod_mime mod_negotiation mod_setenvif mod_ssl mod_suexec mod_userdir sapi_apache2 mod_rewrite

Confixx 3.3.0-pro

I did in /etc/apache2/confixx_mhost.conf

"
<VirtualHost xx.#*$!.#*$!.#*$!:80>

ServerName xyz.de

ServerAlias www.xyz.de *.xyz.de

RewriteEngine on

</VirtualHost>
"

Gives me 403 after server reboot

I did in at httpd.conf all the way at end:

"
<Directory "/home/htdocs/abc123/html">
AllowOverride All
Options +FollowSymLinks +SymLinksIfOwnerMatch
</Directory>
"

After reboot can call site yet when place htaccess get's me 403

Ht access I used:

1.)

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} craiglist\.org [NC]
RewriteRule .* - [F]

2.)

RewriteEngine On
RewriteRule ^ [google.com...] [R,L]

Log error files server/ Error log /var/log/apache2:

1) option above

[Tue Nov 27 18:52:18 2007] [alert] [client #*$!.#*$!.#*$!.#*$!] /srv/www/htdocs/abcxx/html/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps mis-spelled or defined by a module not included in the server configuration

2) option above

[Tue Nov 27 20:59:08 2007] [error] [client #*$!.#*$!.#*$!.#*$!] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /srv/www/htdocs/abcXX/html/

Any advise here to point me in right direction? I could trade some whale watching against it.....

Thanks for any advise, I'm REAL lost here....

gergoe

10:55 pm on Dec 4, 2007 (gmt 0)

10+ Year Member



The first one is not working because of the Unicode BOM [unicode.org] in the top of the .htaccess file; Open the file with a text editor of your choice, and make sure you save it with ANSI encoding. If the editor is not Unicode capable, then remove the "funny" characters from the top of the file before saving.

The second one is missing the

Options +FollowSymLinks
definition, make sure you always include that in your .htaccess files when dealing with mod_rewrite. Please note that the hash mark (#) character is the comment in the Apache configuration files, everything after a hash mark character is being ignored by Apache.

jim_knopf

11:19 pm on Dec 4, 2007 (gmt 0)

10+ Year Member



Hello gergoe

thanks for replying - In regards of the BOM, I did safe the htaccess as required yet still no work, besides - i would get an 403 without a .htacces in place (or does it require to have one)

I will give that option 2 another try considering your suggestion and post results here.

gergoe

11:31 pm on Dec 4, 2007 (gmt 0)

10+ Year Member



Is the DocumentRoot directive intentionally missing from your post, or is that really not in the server config? If it is missing, the Apache will inherit it from the main server config, but usually that directory is quite over-secured, you could easily get 403 errors because of that. Additionally, if your DocumentRoot is pointing to a directory without an index file (defined by the DirectoryIndex directive), and the directory listing is forbidden (
Options Indexes
is not present nowhere), then you can get a 403 as well.

Does the Apache error log not gave any errors about the .htaccess file anymore, after removing the BOM header?

To be honest your posts are a bit confusing, hope I'm not trying to fix a non existing problem :-)

jim_knopf

2:14 pm on Dec 8, 2007 (gmt 0)

10+ Year Member



Hello gergoe,

thanks for your time and sorry I'm not good in explaining... that makes it probably confusing, (besides of me not being a pro in that matters). I try to explain as good as possible what I did now. Sorry for late reply, I run a tourim biz here and the computer / server stuff is only possible when time permits......

Ok I did ad in httpd.conf all the way at end this:

<Directory "/home/htdocs/webxx/html">
AllowOverride All
Options +FollowSymLinks +SymLinksIfOwnerMatch
</Directory>

Reboot server after that and i can call my site up.

I used notepad to create this:

RewriteEngine On
RewriteRule ^ [google.de...] [R,L]

and saved as "all files", Encoding option "ANSI" as .htaccess and uploaded this file with FTP, tranfer typ ASCII to the root directory of my website (webxx, where my index file is)

If I call my site I get a 403 error, when remove the .htaccess i can call my site again.

The error log says:

[Sat Dec 08 15:27:07 2007] [error] [client #*$!.#*$!.x.xx] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /srv/www/htdocs/webxx/html/favicon.ico

So I hope I explained this time better. Any advise what to do? Thanks for the time spend and again, sorry for the confusion.....

jim_knopf

2:54 pm on Dec 8, 2007 (gmt 0)

10+ Year Member



Additional I did try the following I did read on another forum for mod_rewrite;

I ad the line:

Options +FollowSymlinks

in .htaccess and it gives me 500 Internal Server Error

error log says: Options not allowed here

I hope that helps some more.

I have a copy of my httpd.conf file, not sure if ok to post that here....

ANY help is welcome

greetings from La Paz

jdMorgan

3:18 pm on Dec 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok I did ad in httpd.conf all the way at end this:

<Directory "/home/htdocs/webxx/html">
AllowOverride All
Options +FollowSymLinks +SymLinksIfOwnerMatch
</Directory>

This section of code must be placed within your site's <VirtualHost> or <ServerName> container in order to have the desired effect. As indicated by your error log entry, and the fact that you get a 500 error when trying to use Options in .htaccess, it is being ignored.

Jim

jim_knopf

4:33 pm on Dec 8, 2007 (gmt 0)

10+ Year Member



Hi Jim,

if I open the apache2/confixx_vhost.conf

it starts with

UseCanonicalName Off
php_admin_flag safe_mode On
php_admin_value safe_mode_exec_dir /srv/www/htdocs/empty/
LogFormat "%V:#:%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"" confixx
LogFormat "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"" confixx2
CustomLog ¦/root/confixx/pipelog.pl confixx

<Directory "/srv/www/htdocs">
<Files ~ "^\.ht">
deny from all
</Files>
AllowOverride None
AllowOverride Indexes AuthConfig Limit FileInfo
Options None
Options +FollowSymLinks +Includes
</Directory>

and then the different containers for the domains on that
server. So mine would be that below.

<Directory "/srv/www/htdocs/webxx/html">
Options -FollowSymLinks -SymLinksIfOwnerMatch
<IfModule mod_access.c>
Allow from all
</IfModule>
</Directory>

So I add it below the line "Allow from all"?

Just want to make sure and dont screw up for other users of the server.......

Thomas

jim_knopf

4:39 pm on Dec 8, 2007 (gmt 0)

10+ Year Member



Ooops,

further down is more in reference to my site / account in this file:

<VirtualHost xx.#*$!.#*$!.xx:80>
ServerName webxx.h#*$!xx.server#*$!#*$!.net
ServerAlias www.#*$!#*$!xx.com #*$!#*$!xxcom

DocumentRoot /srv/www/htdocs/webxx/html
SuexecUserGroup webxx webxx
ScriptAlias /cgi-bin/ /srv/www/htdocs/webxx/html/cgi-bin/
php_admin_value open_basedir /srv/www/htdocs/webxx/html/:/srv/www/htdocs/webxx/phptmp/:/srv/www/htdocs/webxx/files/:/srv/www/htdocs/webxx/atd/
php_admin_value file_uploads 1
php_admin_value upload_tmp_dir /srv/www/htdocs/webxx/phptmp/
</VirtualHost>

Just in case that would be important....

gergoe

6:40 pm on Dec 8, 2007 (gmt 0)

10+ Year Member



If the DocumentRoot of your website is /srv/www/htdocs/webxx/html, and you make a Directory container which references /home/htdocs/webxx/html, then this two will never match, that's whatever you put into the Directory container, it will be ignored - even if they are actually pointing to the same filesystem paths (symlinks, mount points, whatever options there are).

But as you already have one Directory container in your httpd.conf, why not set your options there? Take this part from the apache2/confixx_vhost.conf file:

<Directory "/srv/www/htdocs/webxx/html">
Options -FollowSymLinks -SymLinksIfOwnerMatch
<IfModule mod_access.c>
Allow from all
</IfModule>
</Directory>

... and change it as follows:

<Directory "/srv/www/htdocs/webxx/html">
AllowOverride All
Options +FollowSymLinks +SymLinksIfOwnerMatch
<IfModule mod_access.c>
Allow from all
</IfModule>
</Directory>

If you are done with that, you can remove the following from your httpd.conf:

<Directory "/home/htdocs/webxx/html">
AllowOverride All
Options +FollowSymLinks +SymLinksIfOwnerMatch
</Directory>

jim_knopf

7:44 pm on Dec 8, 2007 (gmt 0)

10+ Year Member



Thank you so much - that did do it! I'm a very happy camper!
Thank you to Jim also.

it works and I learn somethings.

Was looking for that for weeks when I had time and spend in access of 10 hours of researching and trying to find a solution.

greetings from La Paz

Thomas

jim_knopf

12:21 am on Dec 16, 2007 (gmt 0)

10+ Year Member



Hi all,

I was a happy camper for a few days...
it worked great so I even apply same procedure at some other account on the server that belong to my friend.

Today all the sites get 500 error, on past experience I remove .htaccess and set WP back to regular and it works.

Looking into server / vhost I see that of all the accounts
the

<Directory "/srv/www/htdocs/webxx/html">
AllowOverride All <----------------------------
Options +FollowSymLinks +SymLinksIfOwnerMatch
<IfModule mod_access.c>
Allow from all
</IfModule>
</Directory>

Is gone. I asume confixx is stripping that of when rewriting the file after server changes ( my friend did add a domain by regular means / confixx controls panel.
As far as I understand this is happening when changes done that confixx rewrites that file.

So my question is - where else should I ad that? I have a confixx_vhost.config, confixx_mhost.config and the "regular" httpd.conf file there.

Any advise is welcome

greetings from La Paz

gergoe

11:40 pm on Dec 16, 2007 (gmt 0)

10+ Year Member



Thomas,

Personally I never seen this confix thing myself, so I can only give hints;

First of all, you can apply the changes you did few days ago, so your sites will be back online (but probably you have done that already);
Look into the configuration of this tool, and check the directories. The main problem with the original configuration that your website in question appears with two different file system paths.
Then you should look for parts/settings within the setting of the VirtualHost in question for places, where you can add "custom" directives to Apache, so those will be preserved.
And at last, check the content of the two files you mentioned, if you see similar contain as in your main configuration file, then look for your VirtualHost in those files, and apply the same changes there as you have done in the main server configuration file. Always make backup of files before modifying them!

Last but not least, it is always a good idea to check the manual/help/website of the product where you are facing the problem, you might find the solution there in few moments.

jim_knopf

8:38 pm on Dec 20, 2007 (gmt 0)

10+ Year Member



Hi gergoe,

I found a solution that works (so far....) after tons of more googeling. Confixx is mainly in the german speaking area sold, support plain and simple sucks, their forum does not give much... I found on another forum in GER a hint that there is in admin controll panel a "http special" option one can ad to different users or global. I try that also not work... More research brought me to a site that suggested to insert in httpd.conf BEFORE the include "confixx_vhost.conf" this:

<Directory "/home/htdocs/webxx/html">
AllowOverride All
Options +FollowSymLinks +SymLinksIfOwnerMatch
</Directory>

and that did do the trick! ;-) I also made changes over the control panel and it is alright.

2 more questions. I been told a .htacess file is basically an extension of the server. It just goes "per call" and uses server resources for every call compare to a conf file that does one time at start of Apache.
So could I ad all I have in the http.conf I have in .htaccess?

As example like that:

<Directory "/home/htdocs/webxx/html">
AllowOverride All
Options +FollowSymLinks +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_REFERER} example\.((org)¦(com\.mx))[NC]
RewriteRule .* http://www.example.com/blah.html [R,L]
</Directory>

The second question is right in that example. In the .htaccess file the referer forward did not work.

I cleaned my cache and went to that particular site and clicked the link pointing to my page and did not get forwarded to the URL I used in the .htaccess (of course a "real" one and not example.) I try "http://www.example.com/index.html" as well only "http://www.example.com"

with no success. Any advise on that?

Thanks and good holidays for all here. Seems like webmasterworld is the only reliable source for a "weekend warrior wanabee" like me.

Saludos from La Paz

T.

[edited by: jdMorgan at 9:21 pm (utc) on Dec. 20, 2007]
[edit reason] example.com [/edit]

jdMorgan

9:20 pm on Dec 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This rule may loop if "blah.html" is on your own server. Also, the Referrer pattern is incorrect and is missing a space. Correct it as shown (and replace the broken pipe character with a solid one).

RewriteCond %{HTTP_REFERER} example\.(org¦com\.mx) [NC]
RewriteCond %{REQUEST_URI} !^/blah\.html$
RewriteRule .* http://www.example.com/blah.html [R,L]

In addition, this rule must be placed ahead of your other ruleset, and you must restart your server before it will have any effect.

Differences between .htaccess and httpd.conf or conf.d:

1) .htaccess code is interpreted on a per-HTTP-request basis. Code in http.conf or conf.d is compiled at server restart and is then executed as native code. Therefore .htaccess changes take effect immediately, but the code runs more slowly than it would in httpd.conf or conf.d

2) URL-paths seen by RewriteRule in .htaccess are stripped of the path to the directory in which the code resides. So in /foo/bar/.htaccess this rule

 RewriteRule ^bat\.html$ /bas.php [L] 

would need to be rewritten as
 RewriteRule ^/foo/bar/bat\.html$ /bas.php [L] 

in order to work in httpd.conf.

3) Many directives are restricted to use in httpd.conf or conf.d, for example, RewriteMap and RewriteLogLevel. These directives are not available for use in .htaccess. Each Apache directive description contains a "Context" specification that shows where it may be used.

Jim

[edited by: jdMorgan at 9:22 pm (utc) on Dec. 20, 2007]

gergoe

9:52 pm on Dec 20, 2007 (gmt 0)

10+ Year Member



Few remarks as an addition to Jim's post:
  1. You don't need to enclose directives with a Directory container placed in a VirtualHost container unless you want to set options for a resource other than the root. For example if you want to restrict access to the /secure/ directory, then you will end up using the Dircetory container, but if you want to to the same for the root of your website, it is not needed anymore (except for AllowOverride, but see my next note).
  2. If you really moved all from the htaccess files, then it might be a good move to tell apache that it should not look for htaccess files for this website neither (by default it is off), to do that, simply remove the AllowOverride directive.
  3. RewriteBase is not really needed, as the URL of the website and the filesystem path will certainly match. Will do no harm if you leave it there, just letting you know that it is not needed.
  4. If the first bunch of rules are for making custom 404 error (presenting a custom 'page not found' page), then you would be better off using the ErrorDocument [httpd.apache.org] directive which handles this less resource expensive.