apache - WordPress blog on subdirectory .htaccess redirect -


i have joomla website on root-level, , wordpress blog on /blog .

inside root-level .htaccess, need implement non-www www redirect, such as:

rewritecond %{http_host} ^example.com$ rewriterule (.*) http://www.example.com/$1 [r=301,l]  

however, causes problem when going www.example.com/blog (withoug trailing "/" @ end). redirected http://www.example.com/cgi-bin/php53.cgi/blog/index.php

the php53.cgi file there turn on php 5.3 version. content of file:

#!/bin/sh export php_fcgi_children=3 exec /hsphere/shared/php53/bin/php-cgi 

this .htaccess inside /blog directory:

# begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritebase /blog/ rewriterule ^index\.php$ - [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /blog/index.php [l] # end wordpress 

you need redirect non-www www on both .htaccess since later .htaccess overwrite joomla .htaccess rules.

rewritecond %{http_host} ^example.com$ [nc] rewriterule ^ http://www.%{http_host}%{request_uri} [r=301,l] 

as blog not ending / try rule @ joomla .htaccess:

# redirect /blog /blog/ rewritecond %{the_request} ^[a-z]{3,}\s/+blog([^\s]+) [nc] rewriterule ^blog$ /blog/? [r=301,l] 

note: using %{the_request} because since don't know rules have on joomla .htaccess, above work on cases.

but in simpler way not work in cases depending on other rules have:

# redirect /blog /blog/ rewriterule ^blog$ /blog/? [r=301,l] 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -