mod rewrite - Apache: Remove "www." and redirect to sub directory -


on web server have installed wordpress sub folder /wp.
want use apache's mod_rewrite achieve following:

  1. redirect www.domain.com traffic domain.com
  2. redirect traffic sub folder /wp

i tried following in root's .htaccess file:

rewriteengine on  rewritecond %{http_host} ^(www\.)?domain\.com$ rewriterule ^(/)?$ wp [l]  rewritecond %{http_host} ^www\.domain\.com rewriterule ^(.*)$ http://domain\.com/ [r=permanent,l] 

but not work intended.
ideas doing wrong here?

edit: have solved first requirement changing latter 2 lines to:

# redirect www.domain.com domain.com rewritecond %{http_host} ^www [nc] rewriterule ^.*$ http://domain.com/$0 [r=301,l] 

the second requirement still open though ...

append additional rule:

rewriterule (?!^wp/)^(.*)$ /wp/$1 [l,nc] 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -