1

How can I wildcard redirect urls that share the same url ending? I know if it's www.domain.com/page1/* you can redirect them all this way to a new destination url. However, what if I need to only redirect if it matches the ending of the url string only.

For example, how do I redirect all urls that have the word post_ad.html at the end of them?

So that www.domain.com/page1/feb/post_ad.html (all of these with post_ad.html at the end only) redirects to just wwww.domain.com/postnew.html

4

1 回答 1

0

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule (^|/)post_ad\.html$ /postnew.html [L,NC,R=301]
于 2013-03-30T16:32:07.410 回答