: Which redirect directive with Apache chooose to use among duplicates? We are using Apache server with a .config file to do permanent 301 redirects. The web site is mostly maintained and content
We are using Apache server with a .config file to do permanent 301 redirects.
The web site is mostly maintained and content is provided by the client. This particular web site changes very often, and so I am frequently asked to add to the 301 redirects as the pages change.
This has resulted in multiple redirects for the same URLs as below:
Redirect 301 "/foo/old" "/foo/new"
Redirect 301 "/foo/old" "/foo/bar/new"
Redirect 301 "/foo/old" "/new/foo"
Which one of these redirects will apache use? Configtest tells me that the syntax is OK.
More posts by @YK1175434
1 Comments
Sorted by latest first Latest Oldest Best
Which one of these redirects will apache use?
Apache will process the .Htaccess file from top to bottom. When a condition is met, it processes the condition. When done, Apache will start at the top and process all the rules again to ensure that there are no more matching conditions.
Using your example, once the first rule
Redirect 301 "/foo/old" "/foo/new"
is matched against the condition "/foo/old" it processes the rule and starts again. However, the request is now "/foo/new" and does not match any condition defined within the rules. Therefore only the first rule in your example can be processed. You should only have one rule per condition.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.