Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 3.0 support forum
 Helicon Tech : ISAPI_Rewrite 3.0 support forum
Subject Topic: New to ReWrite Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
DarkMaster
Newbie
Newbie


Joined: 28 September 2008
Location: Slovenia
Online Status: Offline
Posts: 3
Posted: 28 September 2008 at 10:18am | IP Logged Quote DarkMaster

Hello.

Let me say first off that you product is just awesome - considering it works in MS environment (although I am using Lite version...still).

I have some questions on how to proceed on using rewrite engine. I have been experimenting with regexps and have read trough almost every post. I am still just a newbie and much in a need of help - reg-ex are still quite some mystery to me

I have some basic question on how to proceed by using rewrite on my site. Basically, I would like to rewrite my blog articles, categories, tags and perhaps static pages. I see that there are many ways on how to accomplish that. This is my idea - so please correct me on any step...

..my articles are taken from database like this: default.asp?display=1

to have it displayed like: /articles/now-this-is-a-test/, I have been using this settings:

Code:

RewriteMap mapfile txt:mapfile.txt}
RewriteRule ^articles/([^?/]+)/ /default.asp?display=${mapfile:$1}

This work just fine - I have appropriate entries in mapfile.txt - it still works if I just enter default.asp?display=1 - so now problems here yet.

Now I have some questions - to better differentiate site rewrite rules, I am to use more mapfiles - one for articles, one for categories, one for tags right? Is there a better way to do it?
Also, this is not possible without mapfiles? I am asking this because I have some Linux sites and rewrite engine also turned on - for eg. Wordpress uses this mod (directly from apache) - does it also store this mapfile somewhere? How does it manage to rewrite it if not? <- strike this - I found its rewrite slugs to be in database - it seems that it selects data from it, and rewrites afterwards, dunno how..
Also there is some integration question - If I am to use this extension in live production site, and if I add new article, how do I setup automatisation of this rewrite process? I mean I can make my code to append new lines into mapfile.txt - just not sure if this is the best solution. Any suggestion/change would be greatly appreciated.

Will have some more questions later - I hope I can count on your help. Thank you for now, later.



Edited by DarkMaster - 28 September 2008 at 11:34am


__________________
I am the First One.
Back to Top View DarkMaster's Profile Search for other posts by DarkMaster Visit DarkMaster's Homepage
 
Anton
Moderator Group
Moderator Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 4837
Posted: 29 September 2008 at 7:18am | IP Logged Quote Anton

Thanks for such a thorough explanation. I'll try to answer your questions:

Using multiple map files to differentiate rewrite rules is OK. To accomlish this without map file you'll need to write a separate
RewriteRule for each database entry (not really flexible solution).

You may write a script to add new entries to the map file. Changes will be accepted upon the first subsequent request to the map file.

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
DarkMaster
Newbie
Newbie


Joined: 28 September 2008
Location: Slovenia
Online Status: Offline
Posts: 3
Posted: 29 September 2008 at 7:57am | IP Logged Quote DarkMaster

Aham. So I figured. So to have this done in production, the best way to accomplish this is like this:

1. I add an article, it is stored in the database with all the relevant data, for now article ID and slug data: "25" and "test-test-test",
2. an subscript writes into a text file, that holds the map entries for the rewriting rules, it writes: "test-test-test 25",
3. then, when I display articles on the main site, instead of looping trough article links, I display slugs for links and not article IDs anymore,
4. the mapfile and rewrite does all the other work.

Now for eg.:

 add article -> article ID is 25
 OLD: trough loop code on main site, link to article is displayed like "http://www.mysite.org/?display=25"
 I save slug data - the title of the article that is "test-test-test"
 NEW :I then display THAT slug data for link to article instead of querystring like this "http://www.mysite.org/articles/test-test-test/"
 the article is then processed trough mapfile redirect/rewrite(still not quite sure how to use either in different situation)

Did I get it all right?
Or do I have yet to uncover some magic that all current and relevant links get "transformed" and/or rewritten automatically?
I mean - if I go over a link with mouse right now, there is old link with querystring - I want to get all those links to display my mapfile names/slugs instead of querystrings.
I ask this as I want to know just how to proceed on transforming existing data - I get it on the new applications, where you decide from the beginning if you want to have rewriting done or not - but what with the old ones?
I mean I know I can add certain rules and the articles are assessable trough new link names as well as still from querystring calls. I wish to make it all with new names...

Hope I was not too long and too unclear :)



__________________
I am the First One.
Back to Top View DarkMaster's Profile Search for other posts by DarkMaster Visit DarkMaster's Homepage
 
Anton
Moderator Group
Moderator Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 4837
Posted: 29 September 2008 at 8:41am | IP Logged Quote Anton

If you don't want to change old links on pagesm you'll need to have to reverse map files for each url pattern, e.g.
in one map file:
test-test-test 25

in reverse map file:
25 test-test-test

And then if the request is made to old url, it will be redirected to new url and then internally rewritten to the old url.
If the request will be to new url, only internal rewriting will take place.

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
DarkMaster
Newbie
Newbie


Joined: 28 September 2008
Location: Slovenia
Online Status: Offline
Posts: 3
Posted: 29 September 2008 at 8:59am | IP Logged Quote DarkMaster

Great. That is good to hear, because I really did not wish to make all manual changes to every link I have on the site. Thank you for all your time for now. I am sure I will have many more questions and needs for assistance.



__________________
I am the First One.
Back to Top View DarkMaster's Profile Search for other posts by DarkMaster Visit DarkMaster's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
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 can vote in polls in this forum