【问题标题】:How delete "?" from url with .htaccess?如何删除“?”从带有.htaccess 的网址?
【发布时间】:2014-06-18 04:45:43
【问题描述】:

最初的网址是这样的:

site.com/fr/index.php?category/ololo

在 .htaccess 规则之后它看起来像:

site.com/fr/?category/ololo

如何删除“?”类别前的符号?

这是我的 .htaccess 文件:

# URL Rewriting DotClear 2
RewriteEngine On
RewriteRule ^fr/([\w-]+)/([\w-]+)$ index.php?category=$1 [L]

Redirect 301 /dotclear/ /fr/
Redirect 301 /dotclear/public/ /dtc/public

# mod_rewrite


RewriteBase /

RewriteRule ^([^\.]+)\index.php?$ $1 [NC,R=301,L]
RewriteRule ^([^\.]+)$ $1.php [NC,PT,L]


# Generic

#DirectoryIndex index.php index.html
#Options +FollowSymLinks
#Options -Indexes
#php_value register_globals 0

【问题讨论】:

  • /fr/ 是一个真实的目录吗?这个 .htaccess 在哪里?
  • 是的,有 /fr/ 和 /en/ 目录。 CMS 结构
  • 这个 .htaccess 位于何处,您使用的是什么 CMS?
  • @СергейИлларионов 这应该有助于stackoverflow.com/questions/24969396/…

标签: apache .htaccess mod-rewrite


【解决方案1】:

尝试转义“?”

RewriteRule ^([^\.]+)\index.php\?$ $1 [NC,R=301,L]

我已经有一段时间没用过 apache 了,但那可能会...

【讨论】:

  • 之后我得到了这样的网址 site.com/fr/index.php?category/aquarelles
  • 尝试改变一下表达式。匹配每个 URL 并添加 index.php?在 RewriteRule 的第二个参数中。 RewriteRule ^([^\.]+)$ /index.php? [QSA] 之类的东西,如果你想删除 index.php?来自每个网址。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-27
相关资源
最近更新 更多