mod rewrite - Doing external redirect. .htaccess NS flag not working. How to achieve similar results? -


i have moved site in root's subdirectory, want keep url's still working. have achieved using following rule in htaccess:

 rewritecond %{request_uri} !^/subdir  [nc]  rewriterule ^(.*)$ /subdir/$1 [l,ns] 

now problem given page (lets index.php) can accessed 2 url's:

 mysite.com/index.php  mysite.com/subdir/index.php 

i don't want happen avoid confusion users , avoid same content being indexed twice search engines. not htaccess, did external redirect own site creating rule in htaccess:

rewriterule ^subdir/(.*)$ http://mysite.com/$1 [l,r,ns,nc] 

but problem creates endless loop through sub-requests. normal request leads sub-request fetching page "subdir" subdirectory, sub-request causes second rule external redirect site, starting loop on again. ns flag, found out later, useless in case of external redirects. wanted ask is, how break loop? or how transfer request made using "mysite.com/subdir/index.php" url "mysite.com/index.php"?

the first rule posted right

rewritecond %{request_uri} !^/subdir  [nc] rewriterule ^(.*)$ /subdir/$1 [l,ns] 

the second rule you'll have change. should't rewrite redirect (preferably 301).

this helpful both in obtaining desired results , in not getting content indexed twice search engines.

since redirect sends http-response states resource has moved not create internal loop.


Comments

Popular posts from this blog

python - Does anyone know how to configure the hunpos wrapper class on nltk? -