【问题标题】:htaccess rewrite rule all requests to a filehtaccess 重写规则对文件的所有请求
【发布时间】:2014-03-25 21:52:08
【问题描述】:

有人可以帮我改写规则吗?

我想将所有请求重定向到一个文件,但是重定向取决于 url 中的一个字符串。

例如http://domain.com/**v1**/something/something/?querystring 应该被重定向到/**v1**/index.php?q=something/something&querystring

或

http://domain.com/**v2**/something/something/?querystring 应该被重定向到

/**v2**/index.php?q=something/something&querystring

【问题讨论】:

    标签: .htaccess mod-rewrite url-rewriting rewrite


    【解决方案1】:

    你可以在 root .htaccess 中使用它:

    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/(.+)$ /$1/index.php?q=$2 [L,QSA]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多