I'm not very good with mod_rewrite but I really need it now.
I have the whole new website in an folder called site
. So if you need to go the new website the URL would look like http://domain.com/site/...
. Now I need to exclude the site
from the URL but still point it to /site/
EXCEPT for one folder called upload
. How can I do this?
So http://domain.com/anything.ext
and http://domain.com/anyfolder
would point to http://domain.com/site/...
except for domain.com/upload
which still points to domain.com/upload
.
Then another question, is assume this is only good for a temporary solution or doesn't it really matter (thinking of speed and efficiency)?
(Assuming you are putting the rules in a .htaccess file in your document root) use this:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^upload
RewriteRule (.*) site/$1 [L]
If you are putting it into httpd.conf, you need to change it slightly:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/upload
RewriteRule (.*) /site$1 [L]
Regarding the second question, I personally don't like mod_rewrite and certainly wouldn't use it as a permanent solution unless you absolutely have to. This is because mod_rewrite is quite inefficient, especially on busy servers, because it has to run at least one regular expression on every single incoming request. You should always use the [L]
flag to ensure that no more rules than necessary are processed.
It is always more efficient to structure your directories in the same way as the application refers to them. The above should get you working, but try not to leave it in place for too long.
I'm sure you know this already, but here is the mod_rewrite documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With