guess a little tricky problem

Using mod_rewrite to handle various content issues

guess a little tricky problem

Postby nomad_soul » Thu Feb 15, 2007 6:14 am

guys/gals :)

an expert advice is required . i had run around with this problem for many days , n neither anybody could help me .... i have to redirect a fastcgi url to a static file

original url is http://IPAddress/processCgi.cgi?htmlFile=showFile.html

which has to be redirected to

http://IPAddress/processCgi.cgi?htmlFile=showFile.html

I am very new to apache ... any help will be greatly appreciated.

thanks in advance, expecting a reply

RP .....
nomad_soul
 
Posts: 6
Joined: Thu Feb 15, 2007 4:12 am

Postby richardk » Fri Feb 16, 2007 7:40 am

So you want the user to go to /somefile.html but get sent to the CGI file without them knowing? Then put this in a .htaccess file in your document root:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.+\.html)$ /processCgi.cgi?htmlFile=$1 [QSA,L]


Or do you want an actual visible redirect from the CGI file to the HTML file?
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*&)?htmlFile=([^&]+)(&.*)?$ [NC]
RewriteRule ^processCgi\.cgi$ /%2? [NC,R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

sorry for the confusion .. my mistake :(

Postby nomad_soul » Wed Feb 21, 2007 11:30 pm

nomad_soul
 
Posts: 6
Joined: Thu Feb 15, 2007 4:12 am

hi richard....

Postby nomad_soul » Thu Feb 22, 2007 6:13 am

Currently when i try to retrieve this file from browser .. apache webserver is searching for a directory or file by name "processCgi.cgi" (basically the string between ip address and "?" ) n if it doesnt find a file or directory by that name it shows page couldnot be found ... :( its really getting on my nerves .. please help

http://IPAddress/processCgi.cgi?htmlFile=showFile.html is the string

RP
nomad_soul
 
Posts: 6
Joined: Thu Feb 15, 2007 4:12 am

Postby richardk » Thu Feb 22, 2007 11:12 am

Be patient.

/processCgi.cgi?htmlFile=showFile.html redirected to /showFile.html

The second piece of mod_rewrite i posted should do that. Does it not work?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

yes

Postby nomad_soul » Fri Feb 23, 2007 5:25 am

the access log is

10.120.6.55 - - [24/Feb/2007:18:31:53 +0530] "GET /processCgi.cgi?htmlFile=showFile.html HTTP/1.1" 404 289

the error log is

[Sat Feb 24 18:31:53 2007] [error] [client 10.120.6.55] File does not exist: /export/home/kiran/processCgi.cgi

and the rewrite log is

10.120.6.55 - - [24/Feb/2007:18:34:41 +0530] [10.121.34.16/sid#7aa28][rid#107870/initial] (2) init rewrite engine with requested uri /processCgi.cgi

10.120.6.55 - - [24/Feb/2007:18:34:41 +0530] [10.121.34.16/sid#7aa28][rid#107870/initial] (1) pass through /processCgi.cgi

let em know what more details do u require ...

Regards
RP
nomad_soul
 
Posts: 6
Joined: Thu Feb 15, 2007 4:12 am

Postby richardk » Fri Feb 23, 2007 1:51 pm

Is it in a .htaccess file? If it's not, try
Code: Select all
^/processCgi\.cgi$


Or you could create a CGI file that does the redirect instead.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

no luck

Postby nomad_soul » Sun Feb 25, 2007 10:04 pm

i have the following entries in the .htaccess in my documentroot directory.

Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*&)?htmlFile=([^&]+)(&.*)?$ [NC]
RewriteRule ^processCgi\.cgi$ /%2? [NC,R=301,L]


I havent done CGI scripting ever, so that option is :(

do you need some info fromm httpd.conf file?
nomad_soul
 
Posts: 6
Joined: Thu Feb 15, 2007 4:12 am

Postby richardk » Tue Feb 27, 2007 9:28 am

It redirects fine for me. Does this work?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

nopes

Postby nomad_soul » Thu Mar 01, 2007 2:54 am

it doesnt work for me :(
nomad_soul
 
Posts: 6
Joined: Thu Feb 15, 2007 4:12 am

Next

Return to Content

Who is online

Users browsing this forum: No registered users and 9 guests

cron