On 3/28/2014 9:39 AM, Brian Gaber wrote:
This is my first attempt at using RewriteRule.I have about 200 webpages the contain SPS or MENU (in UPPER or lower case) that I want to send to a webpage on another server.I thought this might work, but it has not. RewriteCond %{REQUEST_URI} (SPS|MENU) RewriteRule ^/$ http://new-webserver/new-webpage.html [L]I based this on what I read in http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule and this example found therein:RewriteCond %{HTTP_USER_AGENT} ^Mozilla RewriteRule ^/$ /homepage.max.html [L]I am fairly familiar with Perl Regular Expression, but could someone explain what ^/$ does? I understand what ^ and $ do.Thanks. Brian
Hello,As you probably know, the ^ matches the beginning of the text you're trying to match against. The $ matches the end. The / is simply a literal / character. So the whole pattern matches a line with just a / character.
Are you putting the rules into an .htaccess file or in a server context? If it's .htaccess, the / won't be there to match against because of the way it matches in a "per-directory" context. From the linked page: "The removed prefix always ends with a slash, meaning the matching occurs against a string which /never/ has a leading slash. Therefore, a /Pattern/ with |^/| never matches in per-directory context."
Try something like this: RewriteCond %{REQUEST_URI} (SPS|MENU) [NC] RewriteRule ^.*$ http://new-webserver/new-webpage.html [L]http://rewritetester.com/ is a work in progress, but it might be helpful in showing how mod_rewrite is trying to do the match behind the scenes. It roughly shows what the server would show if you turned on rewrite logging for .htaccess rewrites.
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx