How to 301 redirect static URLs using htaccess

If your website has static URLs i.e. do not contain any query string parameters and you need to redirect your old website URLs to your new website URLs then you don’t have to fear anymore. You can write simple redirect statements in your .htaccess file and you don’t have to be regular expression guru.

Add the following line in your .htaccess file

redirect 301 /oldname 

As you can see in the above statement the htaccess tells the Apache web server to 301 redirect URL if it encounters /oldname to You can add as many statements as you like however if there are over 20 plus URLs then consider using RedirectMatch. You should try your hand at regular expressions and get the job done in few statements.


Leave a Comment