Forum Moderators: phranque

Message Too Old, No Replies

hidden rewrite/redirect?

         

superspyro

5:04 am on Nov 22, 2009 (gmt 0)

10+ Year Member



Hi, I'm been at this for the better part of the day, and I can't seem to figure it out -- maybe 'cause I don't know Apache....

I want to accomplish two things:

1) create a rule so that when people go to http://www.example.com/foo/ it reads from http://www.example.com/foo/bar without showing "bar" in the address line.

2) create a rule that when people go to http://www.example.com/foo/blog/ it reads from http://www.example.com/foo/blog and doesn't try to go to http://www.example.com/foo/bar/blog.

Does that make sense? I'm even confusing myself.

--so very lost...

g1smd

1:33 pm on Nov 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Let's see your code.

It should be two very simple

RewriteRule
lines, with the blog rule listed first so that is processed first.

jdMorgan

5:08 pm on Nov 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I see one RewriteRule, with a RewriteCond exception for /blog path requests.

Jim

superspyro

6:06 pm on Nov 22, 2009 (gmt 0)

10+ Year Member



RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.[^.]+\.example\.com/blog$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^www\.([^.]+)\.example\.com/foo(.*) /public_html/example/foo/bar$1$2

jdMorgan

12:46 am on Nov 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Too complicated, and no exclusion...

Also doesn't match the description you posted above very well.

This should be closer to what you described:


RewriteEngine on
#
# Internally rewrite requests for "/foo/<anything>"
# except "/foo/blog" to "/foo/bar/<anything>"
RewriteCond $1 !^foo/blog
RewriteRule ^foo/(.*)$ /foo/bar/$1 [L]

Jim

superspyro

12:52 am on Nov 23, 2009 (gmt 0)

10+ Year Member



Works great, Jim. Thanks for your help. I have a lot to learn. (: