How does one use mod_rewrite to “move” the appearance of a site directory to the root without actually moving the files? Spot the error in my code?

Without any need of an extra query parameter you can use following rules in your . Htaccess file: Options +FollowSymlinks -MultiViews RewriteEngine on RewriteCond %{THE_REQUEST} ^GET\s/shop/ NC RewriteRule ^shop/(.*)$ /$1 R=301,NC,L RewriteCond %{REQUEST_URI}! ^/shop/ NC RewriteRule ^(.*)$ /shop/$1 L First rule will send 301 to any request from shop/foo to foo in the browser, which is an external redirect Second rule will internally redirect any foo to shop/goo without changing URL in the browser thus making sure your actual files are served from $DOCUMENT_ROOT/shop directory.

Without any need of an extra query parameter you can use following rules in your . Htaccess file: Options +FollowSymlinks -MultiViews RewriteEngine on RewriteCond %{THE_REQUEST} ^GET\s/shop/ NC RewriteRule ^shop/(.*)$ /$1 R=301,NC,L RewriteCond %{REQUEST_URI}! ^/shop/ NC RewriteRule ^(.*)$ /shop/$1 L First rule will send 301 to any request from /shop/foo to /foo in the browser, which is an external redirect Second rule will internally redirect any /foo to /shop/goo without changing URL in the browser thus making sure your actual files are served from $DOCUMENT_ROOT/shop/ directory.

Big thanks for taking your time to help :) – kevin Apr 27 at 22:33 My pleasure, hope that it worked out for you. – anubhava Apr 27 at 22:36.

Try the following (I used your actual url examples): RewriteEngine On RewriteCond %{QUERY_STRING}! Rewrite RewriteRule ^shop/(.*)$ localhost/$1 R=301,NC,L RewriteCond %{REQUEST_URI}! ^\/shop\/ RewriteRule ^(.*)$ /shop/$1?

Rewrite NC,L,QSA The issue you are running into is that when mod_rewrite does the rewrite it is actually performing an Internal Redirect, which causes the rules to applied again. So, this means you have to protect against that, in this case, I've added a parameter rewrite to the URL that the redirect checks for. Hope that helps.

Thanks, I'll try in a bit. Are there any other conditions I could check to get the same result without adding a parameter? I can see this causing problems with needing to pass 'real' parameters through.

Can I test for external vs. internal redirect? – kevin Apr 27 at 19:22 I've added the QSA flag which will append the querystring from the original request to the rewrite. So, /index.

Php? Product=1 -> /shop/index. Php?

Rewrite&product=1. This is really, the easiest solution, in avoiding a the redirect loop. – clmarquart Apr 27 at 19:40 Ah, I understand very clever.

Thanks loads for your help. – kevin Apr 27 at 22:33 The localhost part doesn't work (it redirects the browser to localhost), but replacing it for the explicit full domain it works perfectly, it seems. – kevin Apr 27 at 22:59.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions