2015-03-14 11:59
浏览 382


I have users coming to my website from different sources (forums, blogs...) with links that does not exist no more, so a 404 error shows up. Base on the link they access on my website, I know where to send them. So the links are like this:

and so on

As you can see all the links have and the variable shopc . What I want to do is to redirect to the correct location. Let me give you an example of 2 user accesing my website and what I want to do. So the users are entering my website with this urls:

Right now a 404 error is displayed because that files and dir


does not exist on my website no more. But base on the shopc variable I know where to redirect them.

So the question is: Can I create a .htaccess file to redirect links like


so I can grab the shopc variable and redirect them to the proper location?

图片转代码服务由CSDN问答提供 功能建议

我让用户从不同的来源(论坛,博客......)访问我的网站,链接不存在 没有了,所以出现404错误。 根据他们在我的网站上访问的链接,我知道在哪里发送它们。 所以链接是这样的: 公司/ 445A /?shopc =可变 =可变

和 等等

如您所见,所有链接都有和变量shopc。 我想要做的是重定向到正确的位置。 让我举两个用户访问我的网站和我想做的例子。 所以用户使用以下网址进入我的网站:  /company/b2b/index.php?shopc=variable

现在显示404错误,因为该文件和目录 < 预> <代码> /hsphere/local/home/danuser/ \ N / hsphere /本地的/ home / danuser / /店铺/公司/ B2B / index.php的\ n

我的网站上不再存在。 但基于shopc变量,我知道在哪里重定向它们。



所以我可以抓住shopc变量并将它们重定向到 正确的位置?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

  • dongmouhao7438 2015-03-14 12:44

    In the shop directory's .htaccess file:

    RewriteEngine On
    RewriteBase /shop
    RewriteRule ^.*$ index.php [L,QSA]

    The flag QSA automatically appends the query string on to the substitute request. That's how 'shopc' is passed along. See Apache mod_write online documentation for more.

    When I go to this URL:


    ...I get this output from print_r($_GET) in my /shop/index.php file:

        [shopc] => variable
    解决 无用
    打赏 举报

相关推荐 更多相似问题