Search code examples
.htaccess

htaccess rewrite for default.asp to index.php


Can you please show me how to create rewrite rule in htaccess to convert from default.asp to index.php with the same directory?

Here is what I have so far

RewriteRule ^(.*)\.asp$ ^(.*)\index.php$ [R,L,NC]

But it is not working. I like to be able to convert from defaut.asp to index.php regardless of the URL structure.

For example, if https://myownsite.com/about/that/default.asp then it will become https://myownsite.com/about/that/index.php

Thank you


Solution

  • You can use this :

    RewriteEngine on
    
    RewriteCond %{REQUEST_URI} ^/(.*?)default\.asp$
    RewriteRule ^ /%1index.php [R=301,L]