Skip to content Skip to sidebar Skip to footer

Redirect dynamic url to static url using htaccess

Reading Time: < 1 minute

If you want to redirect bulk of dynamic url to specific / static url, it can do using htaccess file.Here is a example to redirect dynamic urls to specific url using htaccess file.

Think, you have following type of dynamic urls.

http://example.com/category-1/sample-1/details.xml
http://example.com/category-1/sample-2/details.xml
http://example.com/category-3/data/details.xml

In here, example.com and details.xml are static content.category-1,category-3,data…etc dynamic contents.
How to redirect all of above dynamic url to following like static url?
http://example.com/details.xml

How to redirect dynamic url to static url?

Simply put the following script into the htaccess file.

RedirectMatch ^/.+/details.xml$ /details.xml

This is a permanent redirect process named as “301” redirect. So this is not effect to the SEO rank of the site.