Forum Moderators: phranque

Message Too Old, No Replies

[mod_rewrite] remove parts from url

         

natnat

5:45 pm on Jan 17, 2005 (gmt 0)

10+ Year Member



Hello all
I user several rewrite rules on my server and they all work pretty fine.
now I need a new one that says everything with
[my.domain.com...]
will be rewritten to
[my.domain.com...]

only dir should be removed from the url is that possible?

TIA
Chris

Caterham

7:04 pm on Jan 17, 2005 (gmt 0)

10+ Year Member



Hi!
only dir should be removed from the url is that possible?
Sure.

Are you using the rules within a .htaccess in your document root? If so, you can use

RewriteRule ^dir/?(.*) /$1 [R=301,L]

to force the external redirect.

If you place the Rules in the ServerConfig, you should use

RewriteRule ^/dir/?(.*) /$1 [R=301,L]

You should place this rule above all other rules.

This would also match if no trailing slash is used (/dir). Especially yahoo requests "folder paths" without the trailing slash). If you don't need this, you can remove the questionmark to

^dir/(.*)

Bob

natnat

7:40 am on Jan 18, 2005 (gmt 0)

10+ Year Member



works pretty fine bob thanks a lot!