0

My file is here

PassengerMaxPoolSize 25
PassengerPoolIdleTime 10
<VirtualHost *:80>
      RailsEnv development
      # !!! Be sure to point DocumentRoot to 'public'!
      DocumentRoot /myapp/public
      <Directory /myapp/public>
         # This relaxes Apache security settings.
         AllowOverride All
         # MultiViews must be turned off.
         Options -MultiViews
      </Directory>
        RewriteEngine On
        ErrorDocument 503 /system/maintenance.html


#        RailsAllowModRewrite on

         RewriteCond %{REQUEST_URI} !^(home|book-club|blog|login|book-clubs|)$ [NC]
       RewriteRule .? http://blog.mysite.com%{REQUEST_URI} [R=301,L]  
        RewriteCond %{REQUEST_URI} ^/blog
        RewriteRule ^/blog/?(.*)$ http://blog.mysite.com/$1 [P,NC,R=301,L]
        ProxyPass         /blog/ http://blog.mysite.com/
          ProxyPassReverse /blog/ http://blog.mysite.com/

</VirtualHost>

<VirtualHost *:80>
  ServerName blog.mysite.com
  DocumentRoot /var/www/wordpress
  <Directory /var/www/wordpress/>
    Options FollowSymLinks
    AllowOverride All
    Options -Indexes
    Order allow,deny
    allow from all
  </Directory>
</VirtualHost>

I want when user hit http:://www.mysite.com/home or http:://www.mysite.com/book-clubs it redirect to mysite.com/home and http:://www.mysite.com/book-clubs but other than this it redirect to blog.myste.com/<Page-link> Please some one help me.

Ravendra Kumar
  • 1,072
  • 10
  • 29

1 Answers1

0

Put the /blog/ URL first and then check for home, book-club, etc.

RewriteRule ^/blog/(.*)$ http://blog.mysite.com/$1 [NC,R,L]
RewriteRule !^/(home|book-club|login|book-clubs|)$ http://blog.mysite.com%{REQUEST_URI} [R,L]

You don't need the RewriteCond, you can check for the URL path as the pattern in the RewriteRule.

You also missed the leading slash when checking for /home, etc. Omit the slash only, when using RewriteRule inside a .htaccess file or Directory directive.

As a final note, never test with R=301, see this answer Tips for debugging .htaccess rewrite rules for details.

Community
  • 1
  • 1
Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198