473,761 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mod_rewrite in .htaccess does not work

3 New Member
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.co m/$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.co m 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_ispconfi g.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@mydom ain.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.wmlscri ptc .wmlsc .wsc
AddType text/vnd.wap.wml .wml
AddType text/vnd.wap.wmlscri pt .ws .wmlscript
AddType image/vnd.wap.wbmp .wbmp
Alias /error/ "/var/www/web15/web/error/"
ErrorDocument 400 /error/invalidSyntax.h tml
ErrorDocument 401 /error/authorizationRe quired.html
ErrorDocument 403 /error/forbidden.html
ErrorDocument 404 /error/fileNotFound.ht ml
ErrorDocument 405 /error/methodNotAllowe d.html
ErrorDocument 500 /error/internalServerE rror.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.co m: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.co m:80
ServerAdmin webmaster@mydom ain.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 9255
jaanus
3 New Member
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.co m/example.js,
referer: http://host1.mydomain. com/"
Sep 14 '07 #2
jaanus
3 New Member
Already found a solution.
Sep 15 '07 #3

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

Similar topics

5
6477
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 the session variable BUT ... It doesn't work!!! It seems that both set- and readlink open their own private session. How can I get the read-link to access the proper session variable?
3
4072
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 works fine. But When a user accesses through Internet, this does not work.
4
4499
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
2758
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 url, the php page can (obviously) see the *rewritten* url and access it via $_GET. But does php have any access to the *original* url? I'm told that Apache *does* expose both urls (original and rewritten), it's just a question of whether the php...
2
2845
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, the "admin" is used as $1. How can I define the rule for every word given except "admin" ? Thanks in advance!
4
2892
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 when they are clicked. One thing that I have found that they are nested user controls. which do not work. I'm unable to understand what is the problem with that. thanks in advance. Das
7
1835
by: Tom | last post by:
Hi Is this a conditional ? what is the structure of the statement? ch Tom
1
3131
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. Code listed below. Also, can you recommend a book on SQL. Thanks. Dim con As Object Dim rs As ADODB.Recordset
11
3391
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 tasks. How do I get it to work? Thanks, Jim
0
9377
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9925
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9811
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3913
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.