htaccess为多个参数重写干净的url

时间:2015-09-27 05:54:22

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

这是我的Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^[a-zA-Z]{3,}\s/+index\.php\?bank=([^\s&]+) [NC] RewriteRule ^ %1%2%3%4? [R=301,L] RewriteRule ^([^/]+)/?$ index.php?bank=$1$2$3$4 [L,QSA] 代码,用于清理网址重写。

url

此代码适用于rewrites中的单个参数。例如http://example.com/example-path/

http://example.com/index.php?bank=example-path/
url

但是当我尝试在errors中传递多个参数时,我得到的只是http://example.com/example-path

我需要一个像你这样的网址 http://example.com/index.php?bank=example-path代替{{1}}

如何更改我的代码以传递多个网址。

1 个答案:

答案 0 :(得分:2)

您的重定向逻辑可以大大简化为:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

#If a request does not match an existing directory
  RewriteCond %{REQUEST_FILENAME} !-d
#And does not match an existing file
  RewriteCond %{REQUEST_FILENAME} !-f
#then rewrite all requests to index.php
  RewriteRule ^(.*)/?$ index.php?bank=$1 [L,QSA]
相关问题