[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
On 15/11/13 10:24, stinga wrote: > I have a url that comes in as > url1 = /dir1/dir2/dir3/string_part_1/string_part_2/page.html > or > url2 = /dir1/dir2/dir3/string/page.html > > And I want to remove dir1 dir2 dir3 and page.html > > dir1 is static > dir2 and dir3 change > > url1 works > url2 does not > > Here is my RewriteRule > RewriteRule ^/dir1/.*/.*/(.*)/page.html /$1 [R=301] > > Redirect is working but I get > string_part_2 > and I want > string_part_1/string_part_2 > > It has to do with the / in between string_part_1 and Part_2 > > None of the dir's are actually dir's. > > I am stumped... (it is bound to be something really simple) You can try out rewriterules at http://martinmelin.se/rewrite-rule-tester/ which I find quite useful. In your case, the initial .*s catch too much. You want [^/]*, not .*: RewriteRule ^/dir1/[^/]*/[^/]*/(.*)/page.html /$1 [R=301] Anthony -- Author of C++ Concurrency in Action http://www.stdthread.co.uk/book/ just::thread C++11 thread library http://www.stdthread.co.uk Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976 -- The Mailing List for the Devon & Cornwall LUG http://mailman.dclug.org.uk/listinfo/list FAQ: http://www.dcglug.org.uk/listfaq