0

as a php programmer, I usually redirect pages with .htaccess, but having inherited a project formerly made with asp, I need to redirect pages to same-named pages in php. For pages that do not exist in php, index.php should be the redirected page.

Would you please help me with some suggestions and resources? I can only find single page to single page redirect.

Thank you very much

user692942
  • 16,398
  • 7
  • 76
  • 175
Aptivus
  • 433
  • 1
  • 8
  • 24
  • 2
    Use the [Url Rewrite Module](https://stackoverflow.com/a/38262403/692942). – user692942 Apr 18 '19 at 13:55
  • Thanks. The IIS is remote and I cannot install anything on the hosting machine. Or can I just download on a regular Windows machine, execute it and get the resulting file to be then uploaded on the remote server? – Aptivus Apr 19 '19 at 14:46
  • 1
    No, but presumably the remote IIS host will have it installed so all you need to do is configure the rewrite rule in your sites `web.config` file. – user692942 Apr 19 '19 at 16:56
  • But that's what I was asking at first, as I am not into asp. I don't know hiw the web.config has to be built – Aptivus Apr 21 '19 at 13:04
  • Possible duplicate of [IIS URL Rewrite and Web.config](https://stackoverflow.com/questions/4410067/iis-url-rewrite-and-web-config) – user692942 Apr 21 '19 at 14:00

1 Answers1

1

First you have to configure the .Net handlers to process your Classic ASP requests You do that with runAllManagedModulesForAllRequests="true" read more here and here

Next, you can use the built in URL rewrite module to do a wild card replace or a one-to-one map via web.config

As a backup, you can use the Global.asax's Application_BeginRequest event to parse out the requested URL and do a permanent redirect to PHP

Hope this helps

ullfindsmit
  • 279
  • 1
  • 5
  • 20
  • Thank you ullfindsmit, that's beyond my knowledge. I am using the web.config with some regex lines to rewrite the url from ?q=v&q1=v1 to /v/v1/ form, but still cannot redirect all .asp pages to .php relative ones. I would be happy even to redirect all the .asp pages to index.php. This is what I am using, but wih no succes: – Aptivus May 04 '19 at 07:36
  • There Are two things at play here, the first one is making.net handle all your ASP pages, the next is the rewrite . To make ASP.net handle ask request use the run for all m a managed requests setting, next is to do the actual mapping – ullfindsmit May 04 '19 at 13:33
  • How do I instruct the server to the "run for all managed requests"? – Aptivus May 06 '19 at 15:08
  • I have inserted this line of code in the web.config **** but I do not understand how to map the .asp to be redirected all to index.php. Can you please help me? Thank you – Aptivus May 06 '19 at 15:19
  • this is a two step process. Step 1, make .net handle .asp file requests via the runAllManagedModulesForAllRequests="true" Step 2 build your redirect rules. To do a simple test, redirect all .asp to php based on the rule here >> https://forums.iis.net/t/1233447.aspx – ullfindsmit May 06 '19 at 19:10