Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Sep 2012 16:27:10 -0500
From:      Jack Stone <jacks@sage-american.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: Rewrite redirects
Message-ID:  <5066162E.5000108@sage-american.com>
In-Reply-To: <506603BC.8000202@sage-american.com>
References:  <506603BC.8000202@sage-american.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 9/28/2012 3:08 PM, Jack Stone wrote:
> I thought I had this figured out but discovered I have a BIG flaw 
> with my .htaccess redirects After days of searching and 
> experimenting, I still can't get this to do what I intended.
>
> I have moved all of the content on a web site from the web root to a 
> different directory. Now I need toredirect the URL requests from the 
> old location to the new one. Instead of issuing a 301 error, I want 
> to first redirect to an info page, let's call it "info.htm." Here's 
> what I have now in the web root's .htaccess.
>
> Here's the way it was/is:
>
> ~webroot/lots_of.html
> ....and now changed to this:
> ~webroot/content/lots_of.html
>
> Using the apache mod_rewritein .htaccess
> RewriteEngine on
> RewriteRule /~webroot/(.*\.html) /^info.htm [PT]
>
> ....which is supposed to redirect any page with the extension 
> ".html" to the info.htm page. BUT, alas any "*.html page in any 
> directory will redirect back to the info.htm page!! What I wanted is 
> that only the "*.html pages in the ~webroot to be redirected to the 
> info page.
>
> I hope this make sense and I hope someone can give me a tip on how 
> to limit the redirects to only the webroot pages.
>
> Thanks in advance.....
>
For the above, now this works if I use the following:
RewriteBase /~webroot/
RewriteRule ^radio\.html$ /^info.htm [PT]
RewriteRule ^v20\.html$ /^info.htm [PT]

So, now if the above are requested:

http://www.webroot/content/radio.html it doesn't redirect to the info 
page.
That's what I want, but there are 100s of "html" files in 
webroot/content and I figured there MUST be a way to wildcard the 
syntax, something like ^.*\.html$ so I don't need to list every 
specific html file.

I believe I'll have it if I can figure that out now.

Any thoughts?

-- 
--
All the best,
Jack




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5066162E.5000108>