【问题标题】:htaccess redirect dynamic old file to new File urlhtaccess 将动态旧文件重定向到新文件 url
【发布时间】:2014-05-16 06:11:16
【问题描述】:

在上次更新中,我不得不更改站点文件夹,现在需要将旧网址重定向到新路径。旧网址是:

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

新是:

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

如何通过 .htaccess 重定向到新路径.. 只是将 store 重命名为 shop - 其余部分相同.. 谢谢

【问题讨论】:

  • 你当前的 .htaccess 是什么
  • 在当前的 .htaccess 中我没有包含重定向
  • #AddType application/x-httpd-php53 .php #AddDefaultCharset utf-8

标签: php apache .htaccess mod-rewrite redirect


【解决方案1】:

在您网站的根目录中,您需要使用以下代码创建 .htaccess 文件:

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

【讨论】:

    【解决方案2】:

    你需要使用重写规则-

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

    【讨论】:

      猜你喜欢
      • 2012-07-29
      • 2017-09-25
      • 2017-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-14
      相关资源
      最近更新 更多