【问题标题】:Apache, mod_rewrite. Simple and proven RewriteRule doesn't work阿帕奇,mod_rewrite。简单且经过验证的 RewriteRule 不起作用
【发布时间】:2014-05-24 23:29:24
【问题描述】:

动态网址:http://localhost/?langName=spa

重写后的网址:http://localhost/spa

这是.htaccess全部内容

DirectoryIndex ed.php
<IfModule mod_rewrite.c>
  RewriteEngine On
  Options +FollowSymlinks
  RewriteBase /
  RewriteRule //(.*)/(.*)/$ /?$1=$2
</IfModule>

结果:

The requested URL /spa was not found on this server.

Apache/2.0.59 (Win32) PHP/5.2.3 Server at localhost Port 80

请问,哪里出错了? 谢谢!

【问题讨论】:

  • 此 RewriteRule 应将重写的 URL (http://localhost/spa) 转换为动态 URL (http://localhost/?langName=spa)。样本来自RewriteRule Generator

标签: apache mod-rewrite localhost


【解决方案1】:

这应该可以完成工作:

RewriteBase /

RewriteCond %{QUERY_STRING} langName=([a-z]+)
RewriteRule ^$ %1

【讨论】:

  • RewriteRule 必须将重写的 URL 转换为动态 URL。
  • 结果是一样的。此 RewriteRule 应将重写的 URL (http://localhost/spa) 转换为动态 URL (http://localhost/?langName=spa)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-04-05
  • 2012-08-05
  • 2012-12-06
  • 2013-03-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多