Forum Moderators: phranque

Message Too Old, No Replies

Redirect Folder Index Page Only

htaccess mod_alias redirect

         

filemakerguy

7:17 pm on Apr 23, 2008 (gmt 0)

10+ Year Member



I'm trying to do a mod rewrite for an index page of a folder ONLY.

ie http://www.example.net/download/
TO
ie http://www.example.com/download/product-name.html

Is this better to do with RedirectMatch 301

Here's what I've tried, though it doesn't work

RedirectMatch 301 /download/ http://www.example.com/download/product-name.html

I have been trying, but each time I try I end up redirecting all the pages in the folder.

Thanks

[edited by: jdMorgan at 8:37 pm (utc) on April 23, 2008]
[edit reason] example.com [/edit]

jdMorgan

8:43 pm on Apr 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RedirectMatch uses regular-expressions patterns. Because you did not anchor your pattern, it's doing exactly what you told it to do. Try:

RedirectMatch 301 ^/download/$ http://www.example.com/download/product-name.html

This changes the pattern's meaning from the unanchored original "If requested URL-path contains '/download/' then redirect" to "If requested URL-path exactly matches '/download/' then redirect."

For more information on regular expressions, see the tutorials cited in our forum charter, and also in our forum library (links at top of this page).

[added] Also, Redirect and RedirectMatch are processed by Apache mod_alias, not by mod_rewrite, so look for the directives' documentation under mod_alias instead. [/added]

Jim

[edited by: jdMorgan at 8:45 pm (utc) on April 23, 2008]

filemakerguy

8:56 pm on Apr 23, 2008 (gmt 0)

10+ Year Member



Thanks Jim, works beautifully.