Php htaccess将动态旧文件重定向到新文件url
上次更新时,我不得不更改站点文件夹,现在旧URL需要重定向到新路径。。旧的是:Php htaccess将动态旧文件重定向到新文件url,php,apache,.htaccess,mod-rewrite,redirect,Php,Apache,.htaccess,Mod Rewrite,Redirect,上次更新时,我不得不更改站点文件夹,现在旧URL需要重定向到新路径。。旧的是: www.siteexamplename.com/store/index.php?product=240 新的是: www.siteexamplename.com/shop/index.php?product=240 如何通过.htaccess重定向到新路径。。只是将store重命名为shop,其余的都一样。。 谢谢您需要使用重写规则- RewriteEngine on RewriteRule ^oldDi
www.siteexamplename.com/store/index.php?product=240
新的是:
www.siteexamplename.com/shop/index.php?product=240
如何通过.htaccess重定向到新路径。。只是将store重命名为shop,其余的都一样。。
谢谢您需要使用重写规则-
RewriteEngine on
RewriteRule ^oldDirectory/([a-zA-Z0-9-_.]+)$ /newDirectory/$1 [R=301,L]
在网站的根目录中,您需要创建.htaccess文件,其中包含以下代码:
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^store/(.*)$ /shop/$1 [L]
</IfModule>
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^store/(.*)$/shop/$1[L]
您当前的.htaccess是什么在当前的.htaccess中我没有包含重定向#AddType应用程序/x-httpd-php53.php#AddDefaultCharset utf-8