Nathan Pitman
Nathan Pitman

Reputation: 2344

How to allow access to a specific file/folder path with htaccess

I have an .htaccess rule which allows/disallows access based on the domain the site is sitting on. This means I can be sure that the development domain will never be exposed to the likes of a Google Bot. However for a limited time I need to allow unrestricted access to a specific path on the development domain and I'm at a bit of a loss as to how to accomplish this in the context of my existing rules...

# Set environment variables for the dev domain
SetEnvIfNoCase HOST "^dev.domain.com" dev

# If dev
Order Allow,Deny
AuthType Basic
AuthUserFile "/home/domain/subdomains/dev/.dev_htpasswd"
AuthName "Development Domain"
Require valid-user
Allow from all
Deny from env=dev
Satisfy any

I want to allow access to dev.domain.com/foldername but I can;t simply drop another htaccess in the folder because it doesn't actually exist, it's just an endpoint for an application running on the server.

Any thoughts?

Upvotes: 2

Views: 2826

Answers (1)

Jon Lin
Jon Lin

Reputation: 143966

Use the Request_URI:

# Set environment variables for the dev domain
SetEnvIfNoCase HOST "^dev.domain.com" dev
SetEnvIfNoCase Request_URI "/specific/path/" !dev

# If dev
Order Allow,Deny
AuthType Basic
AuthUserFile "/home/domain/subdomains/dev/.dev_htpasswd"
AuthName "Development Domain"
Require valid-user
Allow from all
Deny from env=dev
Satisfy any

and the !dev unsets the variable

Upvotes: 1

Related Questions