【问题标题】:.htaccess rewrite rule redirecting instead of rewriting url?.htaccess 重写规则重定向而不是重写 url?
【发布时间】:2012-03-26 04:30:19
【问题描述】:

这是我的 .htaccess 文件的内容:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^/]+)(/.+)? /negocio$2?shopURL=$1 [L,QSA]

RewriteOptions Inherit

它需要未找到的目录并将它们转换为 php 变量,同时保留 URL 的其余部分。当我去:

http://lujanventas.com/test/asdf

地址栏显示:

http://lujanventas.com/negocio/?shopURL=asdf

(它仍应显示:“http://lujanventas.com/test/asdf”)

做错了什么?

【问题讨论】:

  • 您是否尝试过删除 QSA 标志?
  • 我刚试过。它似乎和以前一样工作。
  • “最初输入的 URL”是什么意思?
  • 当我转到:http://lujanventas.com/test/asdf 我想看到那个 URL 不是 '/negocio/?shopURL=asdf'。
  • /negocio 是一个实际存在的目录吗?

标签: apache .htaccess url mod-rewrite


【解决方案1】:

通过在 2 之后添加 / 来修复它。

RewriteRule ^([^/]+)(/.+)? /negocio$2/?shopURL=$1 [L,QSA]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-09
    • 2022-06-10
    • 2020-11-01
    • 2016-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多