wordpress - htaccess does not redirect primary URI -


i have 2 wordpress installation

example -> contains installation example.com |_ blog -> contains installation example.com/blog 

blog directory inside example has wordpress installation. works fine. wanted redirect users visiting without www (example : http://example.com/blog/some-topic http://www.example.com/blog/some-topic) hence added following wild card rule .htaccess redirection rule inside of blog directory, find below content of .htaccess of 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] </ifmodule>  rewriteengine on rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l]  # end wordpress  # wordfence waf <files ".user.ini"> <ifmodule mod_authz_core.c>     require denied </ifmodule> <ifmodule !mod_authz_core.c>     order deny,allow     deny </ifmodule> </files>  # end wordfence waf 

it redirects correctly uri contains topic like

  • example.com/blog/some-topic redirected www.example.com/blog/some-topic
  • example.com/blog/new-topic redirected www.example.com/blog/new-topic

and on... issue when try redirecting example.com/blog redirects me www.example.com, missing here ?

thanks.

replace last rule this

rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/blog/$1 [l,r,ne] 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -