Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite: insert subdirectory

How to insert a subdir in URL

         

JasonMelton

1:07 am on Aug 4, 2005 (gmt 0)

10+ Year Member



Say the structure of the site has changed, and I don't want to update all the links by hand.

How can I mod_rewrite so that:
www.domain.com/allthatfollows

becomes
www.domain.com/subdir/allthatfollows

Also, is there a tool that will "test" mod_rewrite/.htaccess? That is, I give it my rules or entire .htaccess, pass it a URL, and it tells me the result? I'm tired of breaking my site because my RegEx, .htaccess and mod_rewrite skills are weak!

Thank you!

jd01

2:12 am on Aug 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Jason,

Welcome to WebmasterWorld.

I do not know of a tool that will test for you, I usually use an extra domain, or a subdomain will even work - I normally keep a spare copy of my site here and run tests before 'going live'

We do not normally code on demand, but this should give you a start:

RewriteEngine ON
RewriteRule (.*) /newdirectory/$1 [L]

Hope this helps.

Justin

JasonMelton

12:52 pm on Aug 4, 2005 (gmt 0)

10+ Year Member



Justin,

Thank you!