Forum Moderators: phranque

Message Too Old, No Replies

need mod rewrite help

need mod rewrite help apache .htaccess folder to root

         

Miguelmateos

4:43 pm on Jan 11, 2008 (gmt 0)

10+ Year Member



I can't find this anywhere else at least not code that actually works so I thought I will ask here

I need every page from one directory /handbags/
to go to the root directory /
if a page is a php then it will go to the same php only in the root directory
same with .html all files should go to the index so if the file is

mysite.com/handbags/designerbag-21-p.html I would like it to be redirected to
mysite.com/designerbag-21-p.html

can this be done and if so what code should I use in my .htaccess

any help is appreciated

jdMorgan

5:14 pm on Jan 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can use a simple mod_alias [httpd.apache.org] directive to solve that problem as described:

RedirectMatch 301 ^/handbags/([^.]+)\.(php¦html)$ http://www.example.com/$1.$2

Replace the broken pipe "¦" character above with a solid pipe character from your keyboard before use; Posting on this forum modifies the pipe character.

For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim