RedirectMatch 301 Wildcards Without Variables at the End
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]
精彩评论