The order of redirects matters when doing files and directories ?

Discussion in 'Apache' started by Colbyt, Jan 11, 2010.

  1. #1
    The order of redirects matters when doing files and directories?

    I had a directory with an index.php file and 3 other files and now want to create redirects for all 4 files. The following does not work all the files get redirected to /1/Category-1.html.

    RedirectMatch permanent /Category/ http://localhost/folder/1/Category-1.html
    RedirectMatch permanent /Category/my-file-name-1.php http://localhost/folder/4-my-file-name-One.html
    RedirectMatch permanent /Category/my-file-name-2.php http://localhost/folder/6-my-file-name-Two.html
    RedirectMatch permanent /Category/my-file-name-3.php http://localhost/folder/7-my-file-name-Three.html
    PHP:
    However this version seems to work perfectly on localhost:

    RedirectMatch permanent /Category/my-file-name-1.php http://localhost/folder/4-my-file-name-One.html
    RedirectMatch permanent /Category/my-file-name-2.php http://localhost/folder/6-my-file-name-Two.html
    RedirectMatch permanent /Category/my-file-name-3.php http://localhost/folder/7-my-file-name-Three.html
    RedirectMatch permanent /Category/ http://localhost/folder/1/Category-1.html
    PHP:
    Just moving the directory redirect to the bottom of the list solved the problem.

    cPanel from the control panel does not even seem to offer this as an option, hence my concern about whether it will work or not.
    Will it work as well on a live cPanel server? What's the deal?

    It seems as soon a Apache finds a match it stops reading and executes it even if that match is wrong.
     
    Colbyt, Jan 11, 2010 IP