开发者

RedirectMatch 301 Wildcards Without Variables at the End

开发者 https://www.devze.com 2022-12-09 18:18 出处:网络
How do You do a 开发者_JAVA技巧re-direct a group of pages with a wildcard that doesn\'t attach the variables at the end? For example, the .htaccess code below:

How do You do a 开发者_JAVA技巧re-direct a group of pages with a wildcard that doesn't attach the variables at the end? For example, the .htaccess code below:

RedirectMatch 301 /general/old_events_page.php(.*) http://mysite.org/events

Yields this:

mysite.org/events?id=749&friendly=1&date=20090308

But I just want it to go to http://mysite.org/events


Try this mod_rewrite rule:

RewriteEngine on
RewriteRule ^general/old_events_page\.php$ /events? [L,R=301]


You'll need to use RewriteCond + RewriteRule to achieve this.

RewriteCond evaluates the conditions for which the rule applies

RewriteRule is the rule itself

Anyway... This should the trick;

RewriteEngine on
RewriteCond %{REQUEST_URI} /general/old_events_page.php
RewriteRule .? /events$1? [R=301,L]
0

精彩评论

暂无评论...
验证码 换一张
取 消