This forum has been moved here:
Helicon Tech Community Forum

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x (Forum Locked Forum Locked)
 Helicon Tech : ISAPI_Rewrite 2.x
Subject Topic: Serve .html files as .php
Author
Message |
craigofcapetown
Newbie


Joined: 20 October 2009
Posts: 12
Posted: 12 April 2010 at 5:15am

Hi

I have inherited a website and am having some issues with
it.

I would like to know how to have .html files act as .php
files. ( hope that makes sense )

The two urls below are exactly the same code (simple copy
n paste) but the first one does not work:

http://hospitalityjobsafrica-
com.win32.glodns.net/advancedsearch.html

http://hospitalityjobsafrica-com.win32.glodns.net/crb.php

I am pretty sure there must be a simple way to do this
using isapi rewrite - any ideas out there?

kind regards

Craig
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 12 April 2010 at 5:30am

If you are using ISAPI_Rewrite v2, here's the syntax:

[ISAPI_Rewrite]

RewriteRule /advancedsearch\.html /crb.php [I,L]

__________________
Regards,
Anton
Back to Top
 
craigofcapetown
Newbie


Joined: 20 October 2009
Posts: 12
Posted: 12 April 2010 at 5:39am

Hi

Thanks for the prompt reply! I didn't provide enough info
in my first post.

The issue is that there are hundreds of .html files that
all contain php code. This was done from an SEO point of
view as far as I understand.

So I need something that will enable all of them to run
as php files.

Here, for example is another link:
http://hospitalityjobsafrica-
com.win32.glodns.net/apply.html

As you will see it is not being served correctly either.

Perhaps it is not isapi rewrite that I need to be looking
at?

Craig
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 12 April 2010 at 5:49am

What ISAPI_Rewrite can do is to let you request an html page and (behind the scenes) open the php page, while you'll still see the html page
in the address bar.

For example with the following rule:

RewriteRule /advancedsearch\.html /crb.php [I,L]

you may request http://hospitalityjobsafrica-com.win32.glodns.net/advancedsearch.html but see the content of this page
http://hospitalityjobsafrica-com.win32.glodns.net/crb.php.

If that's what you need, ISAPI_Rewrite is the right solution.

__________________
Regards,
Anton
Back to Top
 
craigofcapetown
Newbie


Joined: 20 October 2009
Posts: 12
Posted: 19 April 2010 at 5:49am

Hi

Thank you for the help so far!

I think my lack of understanding of the code is causing the
biggest problem :-)

On the linux/php server the .htaccess file has the following
code:
< start of code>

php_value error_reporting 2047
php_value display_errors 1
php_flag magic_quotes_gpc off
php_value session.cache_expire 980

DirectoryIndex index.html index.php
RewriteEngine On
Options +FollowSymlinks

RewriteCond %{HTTP_HOST} mysite.com/$   [NC]
RewriteRule ^(.*)$ http://www.mysite.co.za/$1   [R=301]

RewriteCond   %{REQUEST_FILENAME}       !-f
RewriteCond   %{REQUEST_FILENAME}       !-d
RewriteCond   %{REQUEST_FILENAME}       !-f

RewriteRule   ^(.*) index.php?%{QUERY_STRING}


<end of code>

So what it is doing is taking all urls to the index.php file
if they don't exist as actual files.

I have tried to use this on the windows server ( ver 2 of
isapi ) to no avail.

Can someone help out here?

Thanks in advance

Craig
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 19 April 2010 at 7:56am

"I have tried to use this on the windows server ( ver 2 of isapi ) to no avail."\
- the issue is that v2 of ISAPI_Rewrite is an obsolete product which has different syntax.
BUT ISAPI_Rewrite v3 (for any IIS version) or Helicon Ape (for IIS 7, 7,5) support the above syntax with minor changes.
So, please consider using one of these products with the following code:

RewriteEngine On
Options +FollowSymlinks

RewriteCond %{HTTP_HOST} mysite.com$   [NC]
RewriteRule ^(.*)$ http://www.mysite.co.za/$1   [R=301]

RewriteCond   %{REQUEST_FILENAME}       !-f
RewriteCond   %{REQUEST_FILENAME}       !-d
RewriteRule   .* index.php [QSA,L]

__________________
Regards,
Anton
Back to Top
 
craigofcapetown
Newbie


Joined: 20 October 2009
Posts: 12
Posted: 19 April 2010 at 5:50pm

Hi

It does not seem that the hosting company will upgrade.

Is there any way at all for this concept to be written out
for version 2.8?

Kind regards

Craig
Back to Top
 
craigofcapetown
Newbie


Joined: 20 October 2009
Posts: 12
Posted: 19 April 2010 at 6:32pm

Hi

I found this post which seems similar to my issue:

http://www.helicontech.com/forum/forum_posts-TID-13536.htm

What I have tried now is to implement that in my httpd.ini file.

[ISAPI_Rewrite]
RewriteRule (?!/(?:admin/|images/|js/).*).* /index.php [L]


This now enables the links (eg:http://hospitalityjobsafrica-
com.win32.glodns.net/catering_jobs.html , http://hospitalityjobsafrica-
com.win32.glodns.net/conservation_jobs.html ) to work but it is somehow
not picking up the correct data for each page.

Is this on the right track perhaps?

Regards

Craig
Back to Top
 
craigofcapetown
Newbie


Joined: 20 October 2009
Posts: 12
Posted: 19 April 2010 at 7:08pm

Hi

The above post is not working. If I use it the links work
but they don't pick up any data due to the fact that the
php code of the page itself returns no data for
$_SERVER['REQUEST_URI']

Back to the drawing board I guess

Craig
Back to Top
 
craigofcapetown
Newbie


Joined: 20 October 2009
Posts: 12
Posted: 19 April 2010 at 8:03pm

Hi

This :
[ISAPI_Rewrite]
RewriteRule (?!/(?:admin/|images/|js/).*).* /index.php [L]

could work for my scenario if there was a way to pick up the
filename in the php code.

If I implement the above isapi code I don't know how to evaluate the
url in the actual php code as the server variables don't show the
file name.

I guess this part of the original is key:

RewriteRule   ^(.*) index.php?%{QUERY_STRING}

Any ideas?

Craig
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 20 April 2010 at 4:42am

Please try to put the following piece of code into your index.php file to fix the issue:

if (isset($_SERVER['HTTP_X_REWRITE_URL']))
{
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
}

__________________
Regards,
Anton
Back to Top
 
craigofcapetown
Newbie


Joined: 20 October 2009
Posts: 12
Posted: 23 April 2010 at 8:10am

Hi Anton

That piece of code is certainly doing the trick for that
section. Thank you very much for that indeed.

Is that an issue that is brought about by the isapi_rewrite
functionality? If so, would there be a similar effect on
posted form variables?

Kind regards

Craig
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 26 April 2010 at 3:32am

Yes, this issue is due to ISAPI_Rewrite operation.
You can read some more explanation here.

__________________
Regards,
Anton
Back to Top
 
lixiang
Newbie


Joined: 08 September 2010
Posts: 5
Posted: 08 September 2010 at 6:32am

Have you solved the problem!
I also want the answer!


__________________
MAC Eyeliner Cosmetics
Back to Top Visit lixiang's Homepage
 
craigofcapetown
Newbie


Joined: 20 October 2009
Posts: 12
Posted: 08 September 2010 at 12:21pm

Hey lixiang

The information in the message from Anton solved my issues.

if (isset($_SERVER['HTTP_X_REWRITE_URL']))
{
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
}

hth

Crag
Back to Top
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum