Forum Moderators: open

Message Too Old, No Replies

URL Rewrite - Regular Expression

How do I do this.

         

T_Virus

9:01 am on Jun 15, 2006 (gmt 0)

10+ Year Member



Hi All,

I am trying to build a personilsed CMS for my company (well actually the next generation of my previous one). I have decided that as there are two different types of page I need to do the following.

In the root of the website there will be 3 folders.

1. CMS (contains the CMS scripts for basic pages)
2. ASP (contains all the scripts to run certains application areas of the site)
3. HTML (this will contain HTML and HTM pages to form the sites actual structure and file paths).

I have a URL Rewritting tool installed that uses regular expression for the rules. However, I am struggling with learning regular expression. I need to following to happen, any help is greatly appreciated.

If the user clicks on "/internet/widget124.html" then they need to go to "/cms/cms.asp?page=internet-widget124".
^^^
Note the filename and path gets translated into the query string

If the user clicks on "/internet/sow-donut331.htm?someqs=123&anotherqs=abc" then they need to go to "/asp/sow/donut331.asp?someqs=123&anotherqs=abc
^^^
Note the pre-hypen is the folder, the rest of the filename is the script and the query strings also need to be passed.

Please help or show me some easy to understand tutorials. I am completely lost.
George.

T_Virus

9:32 am on Jun 15, 2006 (gmt 0)

10+ Year Member



Would this work?

RewriteRule ^(.*)/(.*)\.html$ /cms/cms.asp?page=$1-$2

AND

RewriteRule ^(.*)/(.*)-(.*)\.htm(.*) /asp/$2-$3.asp$4

T_Virus

10:22 am on Jun 15, 2006 (gmt 0)

10+ Year Member



OK....

The first one is working with ...
RewriteRule (.*)\.html$ /cms/cms.asp?page=$1

I'm then using ASP to convert the / into -

The second one is not working. I keep getting 404. The logging is not working for me the see why.

T_Virus

12:16 pm on Jun 15, 2006 (gmt 0)

10+ Year Member



All working now ...

RewriteRule (.*)\.html$ /cms/cms.asp?page=$1
RewriteRule .*/(.*)-(.*)\.htm[^lL](.*) /asp/$1/$2.asp?$3