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: Understanding the very basics
Author
Message |
aspnewb
Newbie


Joined: 20 April 2011
Location: United Kingdom
Posts: 19
Posted: 20 April 2011 at 9:50am

I I am hosted with open mind hosting, who have ISAPI REWRITE 2 installed, but they dont offer any support for it at all.

It took me a couple of days of testing examples from the v3 example codes to realise that It had to be switched on in the account settings somehow. I eventually found this setting and turned it on. but I am still totally at a loss.

Perhaps I could tell you what I think I understand and you can correct me where I may go wrong?

I believe you need to create a file called: httpd.ini
I have created this file and installed it in the root of my hosting account (The directory where all the website files go...)

My website is in ASP and is database driven with large numbers of categories and products in those categories.

Currently my URL would look something like this for a category:
http://www.mydomain.com/Products.asp?SubCatagoryID=246

However I would like it to look like this:
http://www.mydomain.com/CategoryName/

And for Product pages the URL is currently something like this:
http://www.mydomain.com/ProductDetails.asp?SubCatagoryID=246&ProductID=1421

However I would like it to look like this:
http://www.mydomain.com/CategoryName/Product-Title.html

The website is aways having new categories and products added to it so therefor a way of automatically generating these URLs would be appreciated.

Once it is working I can then reprogram the website to display all the links in the correct new formats. (Unless there is a way to automatically adjust URLs to the new URLs...?)

I would very much appreciate any amd all help you can offer on this.
Thank you inadvance for reading this far, and for your help.
Back to Top
 
aspnewb
Newbie


Joined: 20 April 2011
Location: United Kingdom
Posts: 19
Posted: 21 April 2011 at 11:22am

I dont want to set up loads of rules for all different things, just really for  these 2 examples above. The rest of the website im happy to leave as it is for now.

Can anyone please help?
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 22 April 2011 at 2:05am

Hello,

this
"I believe you need to create a file called: httpd.ini
I have created this file and installed it in the root of my hosting account (The directory where all the website files go...)"
is correct.

But the transformation you want is only achievable in ISAPI_Rewrite 3 or Helicon Ape because they (unlike ISAPI_Rewrite2) support map files and
Helicon Ape can even work directly with databases.

With v2 the only option is having separate rule for each product/category which is quite unacceptable for dynamic site.

So, please consider the options I outlined above.

__________________
Regards,
Anton
Back to Top
 
aspnewb
Newbie


Joined: 20 April 2011
Location: United Kingdom
Posts: 19
Posted: 22 April 2011 at 2:20am

I have no control over it, the hosting company my client are using only have ver 2 installed.

Please could you outline how to create the rules one at a time for the above examples and I will think of a way of dynamicly creating the httpd.ini file from the database.

Thanks
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 22 April 2011 at 3:58am

"I have no control over it, the hosting company my client are using only have ver 2 installed."
- I see. But sometimes you are able to shift to another hosting...

"how to create the rules one at a time for the above example":

[ISAPI_Rewrite]

#category
RewriteRule /Products\.asp\?SubCatagoryID=246 /CategoryName/ [I,RP]
RewriteRule /CategoryName/ /Products.asp\?SubCatagoryID=246 [I,L]

#Product:
RewriteRule /ProductDetails\.asp\?SubCatagoryID=246&ProductID=1421 /CategoryName/Product-Title.html [I,RP]
RewriteRule /CategoryName/Product-Title\.html /ProductDetails.asp\?SubCatagoryID=246&ProductID=1421 [I,L]

But please notice that we do not recommend having more than 150-200 rules in httpd.ini, cause that may hinder the performance.

__________________
Regards,
Anton
Back to Top
 
aspnewb
Newbie


Joined: 20 April 2011
Location: United Kingdom
Posts: 19
Posted: 22 April 2011 at 4:02am

Thank you I will try it.
I didnt realise that I may be able to install Helicon Ape to the account myself. I need to look in to this, if I can and it will support the whole site dynamically I will....

Thanks again
Back to Top
 
aspnewb
Newbie


Joined: 20 April 2011
Location: United Kingdom
Posts: 19
Posted: 22 April 2011 at 5:32am

Ive been shown a way to do it that does work in ver 2, but I need a bit of help with the rules please. Im just focusing on Categories for now.

Here is an example of a way I was shown to get the categories to work with a dynamic site with just the 1 rule:

#category rules
RewriteRule /d(\d+)-pg(\d+)(.*)        /Products.asp\?SubCatagoryID=$1
RewriteRule /d(\d+)(.*)        /Products.asp\?SubCatagoryID=$1

This then turns this:
http://www.mydomain.com/Products.asp?SubCatagoryID=246&Pre-owned-Jewellery
in to this:
http://www.mydomain.com/d246-Pre-owned-Jewellery

(Actually the working bit is just: http://www.mydomain.com/d246 but adding the text on the end which is what I want, still works)
This is Good and it works on all the categories, the problem is that it breaks all the images and style sheets!
Can you please help me to fix this?


Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 22 April 2011 at 8:27am

The images and style sheets are broken because of relative links on pages.
You should convert them into root-relative or absolute format to avoid corruption.
Or you may trying the following rule at the top of your config:

RewriteRule .*\.(?:css|jpg|png|js|etc) $0 [I,L]

As for the rules, they look OK, so if the result satisfies you, use them.

__________________
Regards,
Anton
Back to Top
 
aspnewb
Newbie


Joined: 20 April 2011
Location: United Kingdom
Posts: 19
Posted: 22 April 2011 at 12:06pm

The images and CSS seem to be working ok without using your rule above, (they just suddenly started to work for some reason...!)

What I now wish to do is sort out the product pages,
I need to take a URL like this:
http://www.mydomain.com/ProductDetails.asp?ProductID=1543&N=Product-Name&SubCatagoryID=352

and rewrite it to this:
http://www.mydomain.com/P1543-Product-Name.asp?SubCatagoryID=352

Could you please help with this?
Back to Top
 
aspnewb
Newbie


Joined: 20 April 2011
Location: United Kingdom
Posts: 19
Posted: 25 April 2011 at 5:34am

Ive got the first part working simply by doing a modified copy of the Category rule:


#Products Rules
RewriteRule /P(\d+)-pg(\d+)(.*)\.asp    /productdetails.asp\?ProductID=$1
RewriteRule /P(\d+)(.*)\.asp    /productdetails.asp\?ProductID=$1

This partly works, I can for example now view a product page that was previously accessed witht the URL:
http://www.mydomain.com/ProductDetails.asp?ProductID=1543-Product-Name&SubCatagoryID=352
and view it as :
http://www.mydomain.com/P1543-ProductName.asp

But it doesnt pass over the category information so the  navigation breaks. I need to either be able to use something like:
http://www.mydomain.com/d352/P1543-ProductName.asp
(Which would be the best way) or something like:
http://www.mydomain.com/P1543-Product-Name.asp?SubCatagoryID=352


Please could you help be get this working properly?
Thank you for your time and assistance. It is appreciated.
Back to Top
 
aspnewb
Newbie


Joined: 20 April 2011
Location: United Kingdom
Posts: 19
Posted: 25 April 2011 at 9:44am

Just a slight amendment to the post above the URL that the site was previously access via is:
http://www.mydomain.com/ProductDetails.asp?ProductID=1543&Product-Name&SubCatagoryID=352

Note that it uses an "&" not a hyphen. (Just in case this makes a difference)
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 26 April 2011 at 2:44am

Let's try to modify your rule as follows:

RewriteRule /d(\d+)/P(\d+).*\.asp    /productdetails.asp\?ProductID=$2&SubCatagoryID=$1 [I,L]

Now this request http://www.mydomain.com/d352/P1543-ProductName.asp should direct you to the correct page.

__________________
Regards,
Anton
Back to Top
 
aspnewb
Newbie


Joined: 20 April 2011
Location: United Kingdom
Posts: 19
Posted: 26 April 2011 at 3:53am

Hi Anton, that is almost there, but isnt quite working.
I need to be able to include the name of the Category in the Category Folder.

I need to be able to request this:

http://www.mydomain.com/d352-Catagory-Name/P1543-ProductName.asp

I have tried modifying your rule above, but im afraid I cant do it myself.
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 26 April 2011 at 4:26am

Guess, it should be like this:

RewriteRule /d(\d+).*/P(\d+).*\.asp    /productdetails.asp\?ProductID=$2&SubCatagoryID=$1 [I,L]

__________________
Regards,
Anton
Back to Top
 
aspnewb
Newbie


Joined: 20 April 2011
Location: United Kingdom
Posts: 19
Posted: 26 April 2011 at 4:57am

Hi Anton, that doesnt make any difference the page loads as before, but the images and css dont work, also the breadcrumb picks up the navigation for the category as:
http://www.mydomain.com/d352-Catagory-Name/d3245

If I view this URL I see the category page, but the images etc are broken, if I remove the trailing / it works properly and loads all images etc...

I dont know if that helps, (P.S. is it possible to adjust my user setings so I can post normally please. I keep getting "Spamming not permitted" type messages when I post more than 1 reply within any reasonable time frame.)

Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 26 April 2011 at 5:58am

The images and style sheets are broken because of relative links on pages.
It's advisable to convert them into root-relative or absolute format to avoid corruption.

__________________
Regards,
Anton
Back to Top
 
aspnewb
Newbie


Joined: 20 April 2011
Location: United Kingdom
Posts: 19
Posted: 26 April 2011 at 6:04am

What does that mean, all I know is that for example:

http://www.mydomain.com/d352-Catagory-Name/
Will work but wont show any css or images, however:

http://www.mydomain.com/d352-Catagory-Name
Will work properly and load all css and all images.

Also in the same way:


http://www.mydomain.com/d352-Catagory-Name/P1543-ProductName.asp
Will work but wont show any css or images, however:


http://www.mydomain.com/P1543-ProductName.asp
Will work properly, will load all the images and css, but doesnt pass the Catagory details that it needs to for the navigation to work.

There must be a correct rule syntax to fix this?


Back to Top
 
aspnewb
Newbie


Joined: 20 April 2011
Location: United Kingdom
Posts: 19
Posted: 26 April 2011 at 6:45am

Here is a view of my httpd.ini in case you can spot anything causing the above problem:

#Images & Css
RewriteRule .*\.(?:css|jpg|png|js|etc) $0 [I,L]

#product rules

RewriteRule /d(\d+).*/P(\d+).*\.asp    /productdetails.asp\?ProductID=$2&SubCatagoryID=$1 [I,L]
RewriteRule /P(\d+)-pg(\d+)(.*)\.asp    /productdetails.asp\?ProductID=$1
RewriteRule /P(\d+)(.*)\.asp    /productdetails.asp\?ProductID=$1

#category rules
RewriteRule /d(\d+)-pg(\d+)(.*)        /Products.asp\?SubCatagoryID=$1 [RP]
RewriteRule /d(\d+)(.*)        /Products.asp\?SubCatagoryID=$1
RewriteRule /d(\d+)-pg(\d+)(.*)\        /Products.asp\?SubCatagoryID=$1 [RP]
RewriteRule /d(\d+)(.*)\        /Products.asp\?SubCatagoryID=$1

Back to Top
 
aspnewb
Newbie


Joined: 20 April 2011
Location: United Kingdom
Posts: 19
Posted: 27 April 2011 at 3:49am

I have tried using absolute paths for the images and stylesheets, and while this forces them to load, it still breaks the Navigation and the bread crumb etc.

So the absolute path solution is not the answer.
On other pages that use the rewrite everything including the navigation work perfectly. It is when a forward slash is used after the Category that we get problems.

For example:

http://www.mydomain.com/d352-Catagory-Name/
Will work but wont show any css or images, and the navigation paths get broken, the bread crumb shows the URL as http://www.mydomain.com/d352-Catagory-Name/d352 however:

http://www.mydomain.com/d352-Catagory-Name
Will work properly and load all css and all images, and the navigation shows the correct URL and so does the bread crumb

Also in the same way:


http://www.mydomain.com/d352-Catagory-Name/P1543-ProductName.asp
Will work but wont show any css or images and the navigation paths get broken, the bread crumb back to the category shows the URL as http://www.mydomain.com/d352-Catagory-Name/d352

however:


http://www.mydomain.com/P1543-ProductName.asp
Will work properly, will load all the images and css, but it doesnt pass the Catagory details that it needs to for the navigation to work.

It all seems to be to do with the forward slash used after the category path, it messes everything up for some reason. I dont know if adding a rule to allow a forward slash after the category in the category rules would resolve the problem? Or it might be something to do with the way my rules are set up, (As shown in the post above)

Either way I need to resolve it, because it is breaking the whole site, I need to go live with it, but I cant because of this issue.
Please can you help.

Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 27 April 2011 at 4:38am

Please try to have the following changes in your config:

#Images & Css
RewriteRule .*\.(?:css|jpg|png|js|etc) $0 [I,L]

#product rules

RewriteRule /d(\d+).*/P(\d+).*\.asp    /productdetails.asp\?ProductID=$2&SubCatagoryID=$1 [I,L]
RewriteRule /P(\d+)-pg(\d+)(.*)\.asp    /productdetails.asp\?ProductID=$1 [I,L]
RewriteRule /P(\d+)(.*)\.asp    /productdetails.asp\?ProductID=$1 [I,L]

#category rules
RewriteRule /d(\d+)-pg(\d+)(.*?)/?        /Products.asp\?SubCatagoryID=$1 [I,L]
RewriteRule /d(\d+)(.*?)/?        /Products.asp\?SubCatagoryID=$1 [I,L]

"http://www.mydomain.com/P1543-ProductName.asp
Will work properly, will load all the images and css, but it doesnt pass the Catagory details that it needs to for the navigation to work."
- how do you expect it to pass Category details if the URL doesn't have any category-related info?

__________________
Regards,
Anton
Back to Top
 

Page of 2 Next >>
 
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