redirect subdirectory to subdomain.subdomain.domain
NickName:Mr Beh Ask DateTime:2019-11-29T13:13:15

redirect subdirectory to subdomain.subdomain.domain

i wanted to change the url for my subdirectory from "subdomain1.main.com/subdirectory" to "subdomain2.subdomain1.domain.com"

i tried the htaccess code below but it doesnt work. can someone please help?

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(www\.)?subdomain1\.domain\.com$ [NC]
RewriteRule ^subdirectory/(.*)$ http://subdomain2.subdomain1.domain.com/$1 [L,NC,R=301]

RewriteCond %{HTTP_HOST} ^(www\.)?subdomain2.\subdomain1\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !(jpe?g|gif|bmp|png|tiff|css|js)$ [NC]
RewriteRule !subdirectory%{REQUEST_URI} [NC,L]

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Copyright Notice:Content Author:「Mr Beh」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/59099080/redirect-subdirectory-to-subdomain-subdomain-domain

More about “redirect subdirectory to subdomain.subdomain.domain” related questions

redirect subdirectory to subdomain.subdomain.domain

i wanted to change the url for my subdirectory from "subdomain1.main.com/subdirectory" to "subdomain2.subdomain1.domain.com" i tried the htaccess code below but it doesnt work. can someone please ...

Show Detail

.htaccess redirect subdirectory uri but not the subdirectory itself

I feel like I'm fairly close to this, but it's not quite right. I'm trying to redirect anything after /subdirectory/ (Example: /subdirectory/admin) to the web root. For example /subdirectory/admin

Show Detail

.htaccess - Redirect Subdirectory to Same Subdirectory of another domain

This is quite simple. I need help redirecting the following. I need to redirect a subdirectory from website a to the same to website b. I need this on a wildcard subdirectory, meaning that if I vis...

Show Detail

Redirect external subdirectory in .htaccess

The following code works perfectly to redirect an external URL to a subdirectory on my site: RewriteCond %{http_referer} abc\.com [NC] RewriteRule ^$ my-subdirectory/ [R=302,L] This code tells ...

Show Detail

Redirect all subdirectory child pages to subdirectory root

I've tried to find the answer to the question above and have been unable to do so. Most examples I've found are for redirecting all subdirectory child pages to the root, but not to the subdirector...

Show Detail

Redirect to newdomain/subdirectory

I have been trying to redirect a sub-directory, to a new domain/subDirectory but I am not getting the redirect to work. (ie;) www.oldDomain.co.nz/oldSubDirectory/ to www.newdomain.co.nz/subDirecto...

Show Detail

Redirect whole Subdirectory to Subdomain Subdirectory with .htaccess

Although I know a bit of RegEx I can't figure out, or find an answer here, on how to redirect subdirectory to subdomain's subdirectory. This is not a duplicate because every post here covers how to

Show Detail

NGINX Subdirectory Redirect is not working

TLDR: subdirectory/cool redirects to newdirectory/cool. subdirectory?cool incorrectly redirects to newdirectory without the parameter. The Prob: I'm attempting to redirect a subdirectory to a new

Show Detail

Redirect to subdirectory only if not only in that subdirectory

I am facing a (probably) quite simple problem with my plain old php application. I have a website with a simple directory structure: www.domain.com /blog /some_subdirectory /

Show Detail

htaccess Redirect Domain to Subdirectory

A client wants to redirect a domain (oldsite.com) to a new domain & subdirectory (newsite.com/subdirectory). I have this code setup and it works for for oldsite.com, but when I test oldsite.com/

Show Detail