[英]htaccess rewrite for a folder but not if containing additional url parameters
Is it possible to redirect if a url hits a certain point and when additional url information is added the redirect ignores it? 如果某个URL到达某个点并且添加了其他URL信息后,重定向会忽略它,是否可以进行重定向?
Example: www.mysite.com/myevent/ (would redirect to www.mysite.com/events/) BUT www.mysite.com/myevent/a-random-event-title (would NOT redirect) 示例:www.mysite.com/myevent/(将重定向到www.mysite.com/events/)但www.mysite.com/myevent/a-random-event-title(不会重定向)
The 'a-random-event-title' would be different each time and so cannot be selected specifically. 每次“随机事件标题”都会有所不同,因此无法专门选择。
Thanks 谢谢
Yes you can tweak your regex for that. 是的,您可以为此调整正则表达式。 Consider this rule using
mod_alias
: 考虑使用
mod_alias
规则:
RedirectMatch 302 ^/myevent/?$ /events/
This will ONLY redirect /myevent
OR /myevent/
to /events
while /myevent/anything
will remain unaffected (not redirected) 这只会将
/myevent
或/myevent/
重定向到/events
而/myevent/anything
都不会受到影响(不会重定向)
Place this rule in your DOCUMENT_ROOT/.htaccess
file. 将此规则放在您的
DOCUMENT_ROOT/.htaccess
文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.