2016-03-16 14:05
浏览 198


My old website had urls like:

I need to redirect requests to these files (and only these files) to:

I'm using the Laravel framework that uses a single index.php file.

I've tried:

-Placing files named "search.php" and "product.php" in my root directory that redirects the user.

-Adding to Nginx conf:

location /search.php {
    return 301;     

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

我的旧网站的网址如下:。 php?query = query = id



I 尝试过:

- 在我的根目录中放置名为“search.php”和“product.php”的文件,重定向用户。

- 添加到Nginx conf:

  location /search.php {
 return 301;  
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douzun4443 2016-03-16 14:25

    If your configuration file has a regex location for .php files, such as location ~ \.php$ { ... }. The regex location takes precedence over prefix locations, unless the ^~ modifier is used.

    You have three options: use an exact match location location =, use a regex location, or use the ^= modifier on a prefix location.

    To match two URIs, I might be inclined to use a regex:

    location ~* ^/(search|product)\.php {
        return 301 $scheme://$host/;

    Make sure it is placed above the location ~ \.php$ block.

    See this document for details.

    点赞 评论

相关推荐 更多相似问题