Forums / All Other Contributions/Addons / Ultimate SEO URL's with Isapi ReWrite for IIS6

Ultimate SEO URL's with Isapi ReWrite for IIS6

Locked

Started by bjorn on 2 Feb 2007, 1:51 AM · Views: 18,069

Results 1 to 13 of 13
This thread is locked. New replies are disabled.
2 Feb 2007, 1:51 AM
#1
bjorn avatar

bjorn

New Zenner

Join Date:
May 2005
Posts:
23
Plugin Contributions:
0

Ultimate SEO URL's with Isapi ReWrite for IIS6

If you manage your own server this setup is for you. On a shared hosting account, you will need to contact your provider for the setup of the Isapi_ReWrite filter.

How do we do it?

  1. Visit www.isapirewrite.com and buy the filter. (You can try it free for 30 days)
  2. Install the Isapi filter. Follow instructions to a T. Correct permissions must be set for IIS_WPG group otherwise you will see errors. See install documentation.
  3. Setup the httpd.ini file. We do not use htaccess files, instead we will use httpd.ini files which contain the ReWrite rules. The httpd.ini file must be created in the ROOT of your site.
  4. Insert ReWrite rules. The converted rules are as follows: (insert into the http.ini file)
# From Ultimate SEO URLs
RewriteRule .*-p-(.*)\.html(?:\?(.*))? index.php\?main_page=product_info&products_id=$1?2&$2: [I,L]
RewriteRule .*-c-(.*)\.html(?:\?(.*))? index.php\?main_page=index&cPath=$1?2&$2: [I,L]
RewriteRule .*-m-([0-9]+)\.html(?:\?(.*))? index.php\?main_page=index&manufacturers_id=$1?2&$2: [I,L]
RewriteRule .*-pi-([0-9]+)\.html(?:\?(.*))? index.php\?main_page=popup_image&pID=$1?2&$2: [I,L]
RewriteRule .*-pr-([0-9]+)\.html(?:\?(.*))? index.php\?main_page=product_reviews&products_id=$1?2&$2: [I,L]
RewriteRule .*-pri-([0-9]+)\.html(?:\?(.*))? index.php\?main_page=product_reviews_info&products_id=$1?2&$2: [I,L]

# For Open Operations Info Manager
RewriteRule .*-i-([0-9]+)\.html(?:\?(.*))? index.php\?main_page=info_manager&pages_id=$1?2&$2: [I,L]

# For dreamscape's News & Articles Manager
RewriteRule news/?(?:\?(.*))? index.php\?main_page=news?1&$1: [I,L]
RewriteRule news/rss\.xml(?:\?(.*))? index.php\?main_page=news_rss?1&$1: [I,L]
RewriteRule news/archive/?(?:\?(.*))? index.php\?main_page=news_archive?1&$1: [I,L]
RewriteRule news/([0-9]{4})-([0-9]{2})-([0-9]{2})\.html(?:\?(.*))? index.php\?main_page=news&date=$1-$2-$3?4&$4: [I,L]
RewriteRule news/archive/([0-9]{4})-([0-9]{2})\.html(?:\?(.*))? index.php\?main_page=news_archive&date=$1-$2?3&$3: [I,L]
RewriteRule news/.*-a-([0-9]+)-comments\.html(?:\?(.*))? /index.php?main_page=news_comments&article_id=$1?2&$2: [I,L]
RewriteRule news/.*-a-([0-9]+)\.html(?:\?(.*))? index.php\?main_page=news_article&article_id=$1?2&$2: [I,L]

# All other pages
# Don't rewrite real files or directories

# There is no way to convert these conditions in the current ISAPI_Rewrite version:

# RewriteCond %{REQUEST_FILENAME} !-f [NC]
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^(.*).html /index.php?main_page=$1&%{QUERY_STRING} [L]


# Only rule could be converted to:
RewriteRule (.*)\.html(?:\?(.*))? index.php\?main_page=$1?2&$2: [I,L]

UriMatchPrefix
UriFormatPrefix 
  1. Install the Ultimate SEO Module, enable and you should be set.

If you have problems, DOUBLE CHECK THE INSTALLATION DOCUMENTATION. If you do not set the proper permission on the required directories you will encounter problems with the filter.

There was an attached note from the creators of the Isapi_ReWrite filter for IIS that were rules that could not be converted to the isapi filter format. No issues as of yet.

A big thanks to Blindside who pointed out the Isapi_ReWrite filter for IIS. That spawned the process of working on finding a SEO URL option for IIS users.

Thank you to the chinese ZenCart community who started the original thread on converting the code to Isapi format.

Link 1: Here
Link 2: Here

And lastly, I want to thank Lexey of Helicon Tech who provided the latest rule conversion from the Mod_ReWrite to Isapi_ReWrite. Without his prompt response in rewriting the ruleset we would still be fumbling around for a solution.

See his reponse to my initial question on the Helicon Tech forums here

I hope this provides you with as much excitement as it has me! A solution at last! Cheers,

Bjorn

2 Feb 2007, 10:56 AM
#2
louis avatar

louis

Zen Follower

Join Date:
Jul 2006
Location:
Johannesburg
Posts:
408
Plugin Contributions:
0

Re: Ultimate SEO URL's with Isapi ReWrite for IIS6

Bjorn,

Man, you are a star!!:cheers:

I have spent hours to try and get this working in IIS.

Thanks, Thanks and Thanks again.

2 Feb 2007, 11:22 AM
#3
louis avatar

louis

Zen Follower

Join Date:
Jul 2006
Location:
Johannesburg
Posts:
408
Plugin Contributions:
0

Re: Ultimate SEO URL's with Isapi ReWrite for IIS6

Hi,

I changed the httpd.ini as per your post, activated the re-write and received the following errors:

Line 51: Unrecognized string: UriMatchPrefix
Line 52: Unrecognized string: UriFormatPrefix

Could you PM me your copy of the httpd.ini file (or post as reply to this) so I can compare.

2 Feb 2007, 4:40 PM
#4
bjorn avatar

bjorn

New Zenner

Join Date:
May 2005
Posts:
23
Plugin Contributions:
0

Re: Ultimate SEO URL's with Isapi ReWrite for IIS6

Louis:

Hi,

I changed the httpd.ini as per your post, activated the re-write and received the following errors:

Line 51: Unrecognized string: UriMatchPrefix
Line 52: Unrecognized string: UriFormatPrefix

Could you PM me your copy of the httpd.ini file (or post as reply to this) so I can compare.

Hi Louis,

From the look of the error, the Isapi_ReWrite filter is not configured properly. The UriMatchPrefix and UriFormatPrefix is the replacement code for the ReWriteBase rule for Apache that enables you to specify the relative path of the shop.

Are you using the latest copy of the Isapi_ReWrite filter?

Here is my httpd.ini file:

[ISAPI_Rewrite]

UriMatchPrefix /demo/
UriFormatPrefix /demo/

# From Ultimate SEO URLs
RewriteRule .*-p-(.*)\.html(?:\?(.*))? index.php\?main_page=product_info&products_id=$1?2&$2: [I,L]
RewriteRule .*-c-(.*)\.html(?:\?(.*))? index.php\?main_page=index&cPath=$1?2&$2: [I,L]
RewriteRule .*-m-([0-9]+)\.html(?:\?(.*))? index.php\?main_page=index&manufacturers_id=$1?2&$2: [I,L]
RewriteRule .*-pi-([0-9]+)\.html(?:\?(.*))? index.php\?main_page=popup_image&pID=$1?2&$2: [I,L]
RewriteRule .*-pr-([0-9]+)\.html(?:\?(.*))? index.php\?main_page=product_reviews&products_id=$1?2&$2: [I,L]
RewriteRule .*-pri-([0-9]+)\.html(?:\?(.*))? index.php\?main_page=product_reviews_info&products_id=$1?2&$2: [I,L]

# For Open Operations Info Manager
RewriteRule .*-i-([0-9]+)\.html(?:\?(.*))? index.php\?main_page=info_manager&pages_id=$1?2&$2: [I,L]

# For dreamscape's News & Articles Manager
RewriteRule news/?(?:\?(.*))? index.php\?main_page=news?1&$1: [I,L]
RewriteRule news/rss\.xml(?:\?(.*))? index.php\?main_page=news_rss?1&$1: [I,L]
RewriteRule news/archive/?(?:\?(.*))? index.php\?main_page=news_archive?1&$1: [I,L]
RewriteRule news/([0-9]{4})-([0-9]{2})-([0-9]{2})\.html(?:\?(.*))? index.php\?main_page=news&date=$1-$2-$3?4&$4: [I,L]
RewriteRule news/archive/([0-9]{4})-([0-9]{2})\.html(?:\?(.*))? index.php\?main_page=news_archive&date=$1-$2?3&$3: [I,L]
RewriteRule news/.*-a-([0-9]+)-comments\.html(?:\?(.*))? /index.php?main_page=news_comments&article_id=$1?2&$2: [I,L]
RewriteRule news/.*-a-([0-9]+)\.html(?:\?(.*))? index.php\?main_page=news_article&article_id=$1?2&$2: [I,L]

# All other pages
# Don't rewrite real files or directories

#There is no way to convert these conditions in the current ISAPI_Rewrite version:

#RewriteCond %{REQUEST_FILENAME} !-f [NC]
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*).html /index.php?main_page=$1&%{QUERY_STRING} [L]


#Only rule could be converted to:
RewriteRule (.*)\.html(?:\?(.*))? index.php\?main_page=$1?2&$2: [I,L]

UriMatchPrefix
UriFormatPrefix 

Cheers,

Bjorn

2 Feb 2007, 4:47 PM
#5
bjorn avatar

bjorn

New Zenner

Join Date:
May 2005
Posts:
23
Plugin Contributions:
0

Re: Ultimate SEO URL's with Isapi ReWrite for IIS6

My apologies, I noticed in the first post that the opening UriMatchPrefix / and UriFormatPrefix / were ommited. See post 4 for the correct httpd.ini rules,

Bjorn

26 Jun 2007, 8:41 PM
#6
glitchbit avatar

glitchbit

New Zenner

Join Date:
Jun 2007
Posts:
4
Plugin Contributions:
0

Re: Ultimate SEO URL's with Isapi ReWrite for IIS6

How about this free Isapi Rewrite for IIS6?

http://cheeso.members.winisp.net/IIRF.aspx

This site has an example of reworking the url rewrite rules for IIRF. If anyone could help rework what Bjorn posted, I'd appreciate it very much.

http://www.codinghorror.com/blog/archives/000797.html

it also has logging capabilities that should help diagnose when something does go as expected.

Thanks

27 Jun 2007, 4:21 PM
#7
glitchbit avatar

glitchbit

New Zenner

Join Date:
Jun 2007
Posts:
4
Plugin Contributions:
0

Re: Ultimate SEO URL's with Isapi ReWrite for IIS6

After going over Ionics ISAPI readme file it seems that it already supports everything in that file of yours except.

UriMatchPrefix
UriFormatPrefix

So there is no changing the entire base url, and the solution the joomla people gave was rewritecondition's and rewriterule's much like the ones you already created.

So are these two

UriMatchPrefix
UriFormatPrefix

just there incase you forgot something or what?

Thanks

28 Jun 2007, 12:33 PM
#8
alex_clarke avatar

alex_clarke

Totally Zenned

Join Date:
Mar 2006
Posts:
909
Plugin Contributions:
1

Re: Ultimate SEO URL's with Isapi ReWrite for IIS6

Good job with this Bjorn!

I've followed your instructions (also read your post over at Helicon Tech's forum), but cannot get the Ultimate SEO URLs contribution to work with this!

So far I've installed ISAPI_Rewrite and that works fine. I know it works becuase my website contains various hardcoded links such as '/specials.html' and they all point to the relevant pages (in this case '/index.php?main_page=specials').

The problem I have is that when I turn on Ultimate SEO URLs (from my Zen Cart admin) none of my product links work! The links are generated correctly (so Ultimate SEO URLs is working correctly), but when I click on them the next page appears doesn't load!

The status bar of my browser tells me that it's trying to load the next page an the little status bar progresses, but this process simply repeats... over and over again.

Did you experience a problem like this?

My Contributions: Zen Lightbox | Best Sellers Reloaded

14 Jul 2007, 12:35 AM
#9
bjorn avatar

bjorn

New Zenner

Join Date:
May 2005
Posts:
23
Plugin Contributions:
0

Re: Ultimate SEO URL's with Isapi ReWrite for IIS6

Hi Alex,

What version of ZC and the SEO contrib are you using? Can you provide a link to your cart?

Cheers,

Bjorn

14 Jul 2007, 9:39 AM
#10
alex_clarke avatar

alex_clarke

Totally Zenned

Join Date:
Mar 2006
Posts:
909
Plugin Contributions:
1

Re: Ultimate SEO URL's with Isapi ReWrite for IIS6

Hi Bjorn,

Please find all of the relevant information below.

Zen Cart Version: 1.3.7.1 (Database Version 1.3.7)
Ultimate SEO URLs v2.103

Server is running Windows Server 2003 x64 Standard Edition with IIS 6.0 and ISAPI_Rewrite Lite 2.11.0068.

My httpd.ini file was identical to the one you posted. As previously mentioned, my hardcoded links (for example, '/specials.html', '/contact_us.html', etc...) worked fine. So, ISAPI_Rewrite was working.

Now, I have two problems.

1 - ISAPI_Rewrite seems to block direct access to certain files. For example, my html authentication files (at the root of my site) used by Yahoo and Google.

2 - When I have Ultimate SEO URLs turned on everything seems to be working correctly. Until you click on a link. When clicking on any link the website just attempts to loads the page... over and over again, but makes no progress.

You can access my website by clicking on the link in my signature. At present I've disabled ISAPI_Rewrite and Ultimate SEO URLs.

My Contributions: Zen Lightbox | Best Sellers Reloaded

14 Jul 2007, 10:02 PM
#11
bjorn avatar

bjorn

New Zenner

Join Date:
May 2005
Posts:
23
Plugin Contributions:
0

Re: Ultimate SEO URL's with Isapi ReWrite for IIS6

glitchbit:

How about this free Isapi Rewrite for IIS6?

http://cheeso.members.winisp.net/IIRF.aspx

This site has an example of reworking the url rewrite rules for IIRF. If anyone could help rework what Bjorn posted, I'd appreciate it very much.

http://www.codinghorror.com/blog/archives/000797.html

it also has logging capabilities that should help diagnose when something does go as expected.

Thanks

Hi Glitch,

I'll try squeeze this into my schedule this week. It seems there are some advanced features (from my initial overview IE logging) and the rewrite scripts looks much easier to manage!

I have noticed a bug with the Isapi_ReWrite module from Helitech in that it will not let the web server display .html extension files (This is a ReWrite .httpd file command issue, I'm working with Alex and Helicon to fix this).

I'll let you know what I can produce end of week. Cheers,

Bjorn

28 Jul 2008, 7:24 PM
#12
iam_clint avatar

iam_clint

New Zenner

Join Date:
Jul 2008
Posts:
2
Plugin Contributions:
0

Re: Ultimate SEO URL's with Isapi ReWrite for IIS6

Hey bjorn I made a different approach to this issue and made a custom 404 handler to make this work.

<?php
	$url="";
	$server_location = $_SERVER["REQUEST_URI"];
	$lval = split("/", $server_location);
	$lval = $lval[count($lval)-1];
	$sval = split("\?", $lval);
	$querystring = $sval[1];
	$origurl = $sval[0];
	
	
	function left($str, $length) {
		return substr($str, 0, $length);
	} 

	function right($str, $length) {
		return substr($str, -$length);
	}
	
	function instr($mainstr, $searchstr) {
		if (strpos($mainstr, $searchstr) === false) { return false; } else { return true; }
	}
	
	function getID($type) {
		global $origurl;
		$id = substr($origurl, strpos($origurl, $type)+strlen($type), strpos($origurl, ".")-strpos($origurl, $type)-strlen($type)); /*fancy string work*/
		return $id;
	}
	
	
	function getURL() {
		global $origurl, $url;
		if (instr($origurl, "-c-")) {
				$id = getID("-c-");
				$url="index.php?cPath=$id&$querystring";
		}
		if (instr($origurl, "-p-")) {
				$id = getID("-p-");
				$url="product_info.php?products_id=$id&$querystring";
		}         
		if (instr($origurl, "-m-")) {
				$id = getID("-m-");
				$url="index.php?manufacturers_id=$id&$querystring";
		}       
		if (instr($origurl, "-pi-")) {
				$id = getID("-pi-");
				$url="popup_image.php?pID=$id&$querystring";
		}
		if (instr($origurl, "-pri-")) {
				$id = getID("-pri-");
				$url="product_reviews_info.php?products_id=$id&$querystring";
		}     
		if (instr($origurl, "-t-")) {
				$id = getID("-t-");
				$url="articles.php?tPath=$id&$querystring";
		}
		if (instr($origurl, "-a-")) {
				$id = getID("-a-");
				$url="article_info.php?articles_id=$id&$querystring";
		}   
		if (instr($origurl, "-pr-")) {
				$id = getID("-pr-");
				$url="product_reviews.php?products_id=$id&$querystring";
		}    
		if (instr($origurl, "-i-")) {
				$id = getID("-i-");
				$url="information.php?info_id=$id&$querystring";
		}
		if (instr($origurl, "-links-")) {
				$id = getID("-links-");
				$url="links.php?lPath=$id&$querystring";
		}
		                   
	}
	
	getURL();
		
	if ($url!="") {
		$data = file_get_contents("yoursitehere.com/$url&skip_check=true");
		echo $data;
	} else {
		echo "<center>Page cannot be found, if you feel you have gotten to this page by error please contact an admin [email protected]</center>";		
	}
?>

Modification in the seo code so you can skip the friendly redirect back to the 404 page.

// Ultimate SEO URLs v2.1
  if ((!defined(SEO_ENABLED)) || (SEO_ENABLED == 'true')) {
  	if ($_GET['skip_check']!=true) { 
	    include_once(DIR_WS_CLASSES . 'seo.class.php');
	    if ( !is_object($seo_urls) ){
	      $seo_urls = new SEO_URL($languages_id);
	    }
    }
  }

hope this helps some of you on IIS out.

3 Aug 2009, 2:32 PM
#13
ligrex avatar

ligrex

New Zenner

Join Date:
Oct 2008
Posts:
19
Plugin Contributions:
0

Re: Ultimate SEO URL's with Isapi ReWrite for IIS6

i'm very confused....

I've installed isapi rewrite 3 on my server (IIS6), and i used httpd.ini (uploaded in the root) like Bjorn said but nothing seems work.

I can't set server myself because it's in housing in a farm, but they say that all settings are ok.

They say that errors occour like these:

Unknown expression on line #1: [ISAPI_Rewrite]
Unknown expression on line #3: UriMatchPrefix /backstagericcione.it
Unknown expression on line #4: UriFormatPrefix /backstagericcione.it
Unknown expression on line #39: UriMatchPrefix
Unknown expression on line #40: UriFormatPrefix

I'm really getting crazy... please... can anybody hel me?:frusty::frusty::frusty:

Thanks (and sorry about my english.... :( )