473,320 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

mod_rewrite in .htaccess does not work

3
Here we go...

What I have been trying to do is to forward all http requests containing /cms/ to http://cms.mydomain.com/

example1: http://host1.mydomain.com/cms/init.php would be parsed from http://cms.mydomain.com/init.php (via ajax request)

example2: <script src="http://host1.mydomain.com/cms/example.js" in <html><head> would be parsed from http://cms.mydomain.com/example.js

physically there are no cms directories in http://cms.mydomain.com/ nor in http://host1.mydomain.com/ nor in http://host2.mydomain.com/


/var/www/host1.mydomain.com/web/.htaccess

and

/var/www/host2.mydomain.com/web/.htaccess

look like this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/cms/(.*)$ http://cms.mydomain.com/$1 [P]
</IfModule>

According to phpinfo(), I have mod_proxy and mod_rewrite enabled.

From error log I get "[Thu Sep 13 16:32:55 2007] [error] [client 194.204.*.*] File does not exist: /var/www/web15/web/cms, referer: http://host1.mydomain.com/"

What it means is that there is no url rewriting being done. I checked if .htaccess is being parsed by adding invalid characters into it and I got 500 internal error, which means .htaccess is being parsed.

I use ISPConfig as a frontend for my virtuals. There is a texbox called "Apache Directives". For host1.mydomain.com I have filled it with:

<Directory /var/www/web15/web/>
Options +Includes +FollowSymlinks -Indexes
AllowOverride All
Order allow,deny
Allow from all
<Files ~ "^\.ht">
Deny from all
</Files>
</Directory>

No, I don't want to keep the contents of my .htaccess files in these small texboxes.

cms.mydomain.com has directives for white-listing my proxies:

<Directory proxy:*>
Order Deny,Allow
Deny from all
Allow from host1.mydomain.com, host2.mydomain.com
</Directory>

Here are some relevant sections from /etc/apache2/vhosts/Vhosts_ispconfig.conf

######################################
# Vhost: host1.mydomain.com:80
######################################
#
#
<VirtualHost 195.250.*.*:80>
<Directory /var/www/web15/web/>
Options +Includes +FollowSymlinks -Indexes
AllowOverride All
Order deny,allow
Allow from all
<Files ~ "^\.ht">
Deny from all
</Files>
</Directory>
ServerName host1.mydomain.com:80
ServerAdmin webmaster@mydomain.com
DocumentRoot /var/www/web15/web
DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 index.shtml index.cgi index.pl index.jsp Default.htm default.htm
ScriptAlias /cgi-bin/ /var/www/web15/cgi-bin/
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
ErrorLog /var/www/web15/log/error.log
AddType application/x-httpd-php .php .php3 .php4 .php5
<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
</Files>
<Files *.php3>
SetOutputFilter PHP
SetInputFilter PHP
</Files>
<Files *.php4>
SetOutputFilter PHP
SetInputFilter PHP
</Files>
<Files *.php5>
SetOutputFilter PHP
SetInputFilter PHP
</Files>
php_admin_flag safe_mode Off
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
AddType application/vnd.wap.wmlscriptc .wmlsc .wsc
AddType text/vnd.wap.wml .wml
AddType text/vnd.wap.wmlscript .ws .wmlscript
AddType image/vnd.wap.wbmp .wbmp
Alias /error/ "/var/www/web15/web/error/"
ErrorDocument 400 /error/invalidSyntax.html
ErrorDocument 401 /error/authorizationRequired.html
ErrorDocument 403 /error/forbidden.html
ErrorDocument 404 /error/fileNotFound.html
ErrorDocument 405 /error/methodNotAllowed.html
ErrorDocument 500 /error/internalServerError.html
ErrorDocument 503 /error/overloaded.html
AliasMatch ^/~([^/]+)(/(.*))? /var/www/web15/user/$1/web/$3
AliasMatch ^/users/([^/]+)(/(.*))? /var/www/web15/user/$1/web/$3
</VirtualHost>

######################################
# Vhost: cms.mydomain.com:80
######################################
#
#
<VirtualHost 195.250.*.*:80>
<Directory proxy:*>
Order Deny,Allow
Deny from all
Allow from host1.mydomain.com, host2.mydomain.com
</Directory>
ServerName cms.mydomain.com:80
ServerAdmin webmaster@mydomain.com
DocumentRoot /var/www/web17/web
DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 index.shtml index.cgi index.pl index.jsp Default.htm default.htm
ScriptAlias /cgi-bin/ /var/www/web17/cgi-bin/
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
ErrorLog /var/www/web17/log/error.log
AddType application/x-httpd-php .php .php3 .php4 .php5
<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
</Files>
<Files *.php3>
SetOutputFilter PHP
SetInputFilter PHP
</Files>
<Files *.php4>
SetOutputFilter PHP
SetInputFilter PHP
</Files>
<Files *.php5>
SetOutputFilter PHP
SetInputFilter PHP
</Files>

I have no clue what could be wrong, I have Googled a whole day, trying everything out with no results :(
Sep 13 '07 #1
2 9230
jaanus
3
Seems like mod_proxy is being used by mod_rewrite.
mod_rewrite can be used in htaccess files while mod_proxy cannot. I moved apache directives into apache main configuration files and now the requests are being redirected.

New problem has risen though. I get the following error:

"[Thu Sep
13 23:10:56 2007] [error] [client 194.204.*.*] client denied by
server configuration: proxy:http://www.mydomain.com/example.js,
referer: http://host1.mydomain.com/"
Sep 14 '07 #2
jaanus
3
Already found a solution.
Sep 15 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Peter | last post by:
L.S. I am developing a PHP-login script (on Lycos Tripod) that uses Session to pass on variables. Below is the entire (stripped) structure that I use. It opens a page where you can Set and Read...
3
by: cv | last post by:
Hello All, I have used MultipartRequest like the following to upload images. MultipartRequest multi = new MultipartRequest(request, "../webapps/coreprogram/dealerlogos", 1024 * 1024); It...
4
by: Field | last post by:
Hi, the following snippet shows once executed this output: 2 2 I'd have rather expected this output: 2 10
2
by: Jon Maz | last post by:
Hi All, Forgive a newbie-ish question here, but I've not been long in the Apache / PHP world. I'm just learning about mod_rewrite, and a question occurred to me. Once Apache has rewritten a...
2
by: Geradeaus | last post by:
I use htaccess to rewrite the url using the following rules : RewriteRule ^(+)/(+)/(+)?$ index.php?lang=$1&page=$2&id=$3 The only problem I have is when http://www.domain.com/admin is given,...
4
by: Das | last post by:
Hi, I have made an application in ASP.net with C#. The application works fine with localhost. I have uploaded the site. I'm using web user controls in the form. but some of the button do not work...
7
by: Tom | last post by:
Hi Is this a conditional ? what is the structure of the statement? ch Tom
1
by: Newbie in ChiTown | last post by:
Here's my code: I am using MS Access and I am trying to update a table (InvoiceDetails) with data input by the user on a form. However, it does not update nor does it give me an error message. ...
11
by: Jim | last post by:
Hi, I want to schedule a Python program that reads the command line for input. However, when adding an argument to the command line Python will not pick it up when using Windows scheduled...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.