简体   繁体   English

htaccess将动态旧文件重定向到新文件url

[英]htaccess redirect dynamic old file to new File url

with the last update I had to change site folder and now old urls need to be redirected to the new path.. old was: 在上次更新中,我不得不更改站点文件夹,现在需要将旧网址重定向到新路径。

www.siteexamplename.com/store/index.php?product=240    

new is: 新的是:

www.siteexamplename.com/shop/index.php?product=240

how to redirect via .htaccess to the new path.. just to rename store to shop - the rest is the same.. thanks 如何通过.htaccess重定向到新路径..只是将商店重命名为shop-其余相同..谢谢

You need to use rewrite rule- 您需要使用重写规则-

RewriteEngine on
RewriteRule ^oldDirectory/([a-zA-Z0-9-_.]+)$ /newDirectory/$1 [R=301,L]

In the root directory of your Website you need to create .htaccess file with next code: 在您网站的根目录中,您需要使用以下代码创建.htaccess文件:

<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^store/(.*)$ /shop/$1 [L]
</IfModule>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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