Forum Moderators: phranque

Message Too Old, No Replies

help to rewrite multiple directories to one

rewrite directroy help

         

adimo

11:49 am on May 3, 2009 (gmt 0)

10+ Year Member



Hi, I hope someone here can help with this one as i am still new to mod rewriting

I am rewriting psudo urls for a project but I need a files directory to match these psudo names. the system can rewrite many sub level folders too.

psudo url = domain.com/somesub/somesubtwo/blah/blah/docs/image.jpg

real url = /docs/image.jpg

the docs directory will be on root.

so far I have tried
RewriteRule ^(.*)/docs/$ docs/$1 [L]

thank for any help

jdMorgan

6:25 pm on May 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You didn't explain "what exactly is wrong" when you test this code, but I'd suggest:

RewriteRule ^(.+)/docs/$ /docs/$1 [L]

Be aware that this creates massive duplicate-content issues on your site, which can harm your rankings, and which can be exploited by competitors to harm your rankings. Be sure that you have some mechanism in place (i.e. a script at /docs/ ) to check that all parts of the "/somesub/somesubtwo/blah/blah" are one single correct value -- or at most a small number of values (only two or three).

If multiple values are allowed, then the script must produce unique content for each allowed value. Otherwise, this whole plan does not sound like a good idea... Try a search on "duplicate content" here on WebmasterWorld to read some of the potential problems.

In simple terms, for each resource defined on your site by its unique content, that resource should be accessible by one and only one canonical URL, and all non-canonical variations of that URL should redirect to the canonical URL or return 404-Not Found or 410-Gone.

Jim

adimo

1:51 pm on May 4, 2009 (gmt 0)

10+ Year Member



Thanks for your help there Jim
Both methods bring a 404 back when I try to access

domain.com/somesub/somesubtwo/blah/blah/docs/image.jpg