HTACCESS:正则表达式匹配替换为网址-多个选项

时间:2018-09-23 07:55:45

标签: regex .htaccess url replace rules

我希望htaccess使用正则表达式执行以下操作:

  

http://www.website.com/?module=browse更改为http://www.website.com/browse

问题是,我具有遵循相同开始模式的更复杂的链接,但包含更多项,例如:

  

http://www.website.com/?module=watch&id=5&season=1&episode=1

到目前为止,我的规则:

RewriteEngine On
Options -Indexes
DirectoryIndex index.php
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^about$ /?module=about [L]
RewriteRule ^browse$ /?module=browse [L]
RewriteRule ^contact /?module=contact [L]
.
.
.
RewriteRule ^watch/(.*)/(.*)\.html$ /?module=watch&id=$1 [L]

是否有一种更简单的解决方案,将所有链接都包含为一个替换项(而不是每个页面都有一个新行替换项)?

0 个答案:

没有答案