简体   繁体   中英

htaccess file still best way to redirect .htm to .php version of file?

I am ready to launch a new version of an existing site which currently has all .htm files and the new files will be exactly the same name but with a .php extension - is updating the htaccess file with:

RedirectMatch 301 (.*)\.htm$ $1.php 

still the best way to redirect all of these files?

I have never done this through the htaccess file, I have read the change is immediate.

I found this answer on this site but it was from 2012 so I just want to be sure it is still the best solution.

Adding RedirectMatch 301 ^(.+?)\\.htm$ $1.php into your .htaccess file should be fine if you're running Apache.

However, if you're using nginx for example, you cannot use .htaccess files.

(If you're using nginx, try taking aa read here .)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM