[英]htaccess rewrite clean url for multiple parameters
这是我的.htaccess
代码,用于干净的URL重写。
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
如何更改我的代码以传递多个URL。
您的重定向逻辑可以大大简化为:
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]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.