开发者

htaccess redirect folder to another folder

开发者 https://www.devze.com 2023-03-09 00:04 出处:网络
how do I redirect http://mysite.com/folder开发者_JS百科/category-old/ to http://mysite.com/folder/category-new/?

how do I redirect http://mysite.com/folder开发者_JS百科/category-old/ to http://mysite.com/folder/category-new/?

NOTE: 1. the same 'category' exists in all folders. 2. "folder" is variable and could be "folder2" or "folder3" 3. the final folder will always be /category-new/


Use mod_rewrite. Place something like this in .htaccess in the root directory:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)/category-old/(.*)$ $1/category-new/$2 [R,L] 

See http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html for more info.

0

精彩评论

暂无评论...
验证码 换一张
取 消