.htaccess Remove .aspx ending on wordpress

old site uses index.aspx or service-type.aspx

New site uses or service-type

Read More

which is now wordpress

I tried many syntax posted on SO doesn’t seem to redirect at all.. Not sure what my mistake is.

htaccess file

# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.aspx -f
RewriteRule ^(.*?)/?$ $1.aspx [L]

RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Have tried other SO posted solutions but always ends up on 404 for wordpress.

Related posts

Leave a Reply

1 comment

  1. You would like to remove .aspx from old links. Have your .htaccess like this:

    # BEGIN WordPress
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{THE_REQUEST} s/+(.*?/)?(?:index)?(.*?).aspx[s?] [NC]
    RewriteRule ^ /%1%2 [R=302,L,NE]
    
    RewriteRule ^index.php$ - [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress