【问题标题】:.htaccess rewrite rule for one GET variables on index.php?index.php 上一个 GET 变量的 .htaccess 重写规则?
【发布时间】:2015-02-07 22:25:52
【问题描述】:

.htaccess 重写 index.php 上一个 GET 变量的规则?

我知道 2 个变量的工作原理

RewriteRule ^(.*)/(.*)$ /index.php?var1=$1&var2=$2 [NC,L]

.htaccess rewrite rule for two GET variables on index.php?

一个人怎么办??? index.php?var1=$1

【问题讨论】:

  • 我不明白你为什么这么问。为一个变量简化它有那么难吗?
  • 同一个例子可没那么容易。因为你必须测试文件的存在以避免任何循环问题。

标签: php .htaccess variables mod-rewrite indexing


【解决方案1】:

使用这个.htaccess:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ index.php?var1=$1 [L]

【讨论】:

  • 对我来说在 .htaccess RewriteRule 中工作 ^(\w+)/?$ index.php?id=$1 谢谢
  • 不客气。没有太大区别:我的意思是:不是/。你的意思是[a-zA-Z0-9_]。有些角色会接受我的而不是你的(比如.)。
猜你喜欢
  • 2013-07-11
  • 1970-01-01
  • 2013-10-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-19
  • 2021-12-18
  • 2017-07-08
相关资源
最近更新 更多