Hello. I have a .htaccess who redirect all request do the /public/ directory. But i want only redirect when no subdomain… Actual .htaccess :
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
Thanks.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @Simsimpicpic,
You can use something like the following
RewriteCond %{HTTP_HOST} !^static1\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^static2\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^static3\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} (\.|^)example\.com [NC]
RewriteRule .* http://www.example.com/public [R=301,L]
You’ll need to change the static1/2/3 with your actual subdomain and the example.com with your domain.
Regards, KDSys
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.