简体   繁体   中英

Redirect all the .php files of root folder (old URLs) to new folder, with .htaccess

I need to redirect all the .php files of root directory (old URLs) to the same files which have been moved to a new directory (new URLs), with .htaccess.

eg:

something.com/handsome.php , something.com/index.php

to

something.com/fold/handsome.php , something.com/fold/index.php

etc. Also:

something.com/hector/handsome.php

to

something.com/fold/hector/handsome.php

Please help, Thanks.

I think the correct syntax for you would be:

Redirect 301 /handsome.php http://www.something.com/fold/handsome.php
Redirect 301 /index.php http://www.something.com/fold/index.php
Redirect 301 /hector/handsome.php http://www.something.com/fold/hector/handsome.php

in the .htaccess file. Further detalis here: http://www.htaccess-guide.com/redirects/ .

Redirect using htaccess

RedirectMatch 301 something.com/handsome.php(.*) something.com/index.php$1

RedirectMatch 301 something.com/fold/handsome.php(.*) something.com/fold/index.php$1

RedirectMatch 301 something.com/hector/handsome.php(.*) something.com/fold/hector/handsome.php$1

You can redirect using htaccess tools http://www.webconfs.com/htaccess-redirect-generator.php

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