Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Need help on rewrite!

Please, help with that.



8:23 pm on Dec 16, 2001 (gmt 0)

10+ Year Member

I have a problem with the cloaking script set up.. With no specific titles.:)
I place the following to the .htaccess file.:

AddType text/x-server-parsed-html .html

RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.html$ cgi-bin/cloak.pl?name=$1.html [T=application/x-httpd-cgi,L]

RewriteRule ^(.*)\.htm$ cgi-bin/cloak.pl?name=$1.htm [T=application/x-httpd-cgi,L]

What I want is to get the request for the page to go through the script..
But I get "Page not found" for any .htm or .html file request. Although, seems like Rewrite directive is allowed ( error log stays the same)
So, something wrong with that, but what???
Would be greatly appreciate for that!
Thank you!


5:52 am on Dec 17, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

You don't really need the rewrite, the line in .htaccess to make a file named with a .htm extension be treated as a .cgi is as follows:

AddType application/x-httpd-cgi .htm

Now just name the script as the pagename-you-want.htm and it will execute. But some of this depends on how your script retrieves pages. Are they inline? i.e. is the HTML source code embedded in the script or does the script read the pages to display from a file? The example here is for a script with inline HTML source.


5:59 am on Dec 17, 2001 (gmt 0)

10+ Year Member

Thanks, Air. But they are not inline. I want the solution to cloak the site, although the pages are in usual files easy for updating. The script takes the file as the parameter .. Then checks for the IP. If that is the SE (Google), then it takes the same file from the directory /Google/.
I mean, for example, you accessed the index.html file.
That goes like /cgi-bin/cloak.pl?name=index.html
The script checks the IP and takes the index.html from the right directory.
It just Opens and prints the file..
Makes sense???
Would be greatly appreciate for that!

Thank yoU!


2:32 pm on Dec 17, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Ok, then try this (hope you have SSI available).

In your .htaccess file add the following:

AddHandler server-parsed .htm

In the pagename-you-want.htm have the single SSI statement:

<!--# include virtual = "/cgi-bin/cloak.pl?name=pagename-you-want.htm" -->

The AddHandler statement in your .htaccess allows files with .htm extension to be server parsed. The SSI statement will call the script and execute it, passing the parameter name=pagename-you-want.htm

Also remove the AddType application/x-httpd-cgi .htm statement from your .htaccess, you shouldn't need it.


Featured Threads

Hot Threads This Week

Hot Threads This Month