I need htaccess that will redirect users accessing subdirectories of specific directory (one that contains htaccess) to corresponding subdirectories on another server.
For example:
server_1/dir_with_htaccess/user_subdir_of_choice ---> server_2/user_subdir_of_choice
No subdirectory woudl actually exist on first server, it woudl just contain htaccess.
Related
Does anyone know how I could achieve the following with .htaccess?
If the file does not exist but folder exists, redirect to folder
If the file is in the root directory, or folder does not exist, redirect to home page "/"
For example, if we have to take a request to www.domain.com/folder/file.html:
If /folder/file.html exists, we just show it as is, no redirect.
If /folder/file.html does NOT existing but /folder/ does exist, we redirect to /folder/
If then /folder/ does not exists we redirect to "/" We need this done in a generic way so that we do not need to hardcode the folder or file names into the .htaccess file.
Should work for all file types with a way to set up exclusions (both for folders and filetypes)
Because of my host system I have different folders for some domains(domain.com, domain2.com, domain3.com)
DomainFolder
DomainFolder2
DomainFolder3
Every domain should point to Domain, but the host told me that they work only in that way for multiple domains and that I should write a .htaccess on Domain1, Domain2, etc to send that domains point to DomainFolder.
How can I make that a htaccess changes the request file from DomainFolder1 to DomainFolder?¿?¿?¿?¿?
I need to dynamically rewrite urls in Apache by reading the mapped destination url from an alias file (one for each url). Here is my directory structure:
/websites
/.aliases
alias-of-site-1 (file containing 0ad5c94df074c13f)
alias-of-site-2 (file containing 50d9a12e9619d041)
(...)
/0ad5c94df074c13f (website subdirectory for alias-of-site-1)
/50d9a12e9619d041 (website subdirectory for alias-of-site-2)
(...)
When a visitor navigate to http://example.com/alias-of-site-1, I need to read the real subdirectory of the website from the file /websites/.aliases/alias-of-site-1, then rewrite the url as http://example.com/0ad5c94df074c13f
I find the Apache RewriteMap directive, but it only seems to work when all key / values are in one file. In my case, each alias has its own file.
I currently have my main page at www and some files at www/files/.
How could I block the access to /files itself, but allow users to access www/files/ without having to give each folder a separated .htaccess file and without changing my current htaccess file at www?
I have one .htaccess file (all subdomains point at the same file directory as the main domain, so one .htaccess file would need to accomplish this). What I'm trying to do is this: any current and future subdomains should redirect like so:
sub1.example.com/cart
sub2.example.com/cart
sub3.example.com/cart
unknown_future_subdomain.example.com/cart
Those 4 subdomains and specific /cart path should all redirect to example.com/cart
I have tried different solutions but they caused redirect loops, I think because the sames .htaccess file is loaded on the main domain.