Redirect from Initial Domain (Specific Directory) to Own Domain

Asked 1 years ago, Updated 1 years ago, 65 views

Thank you for your help.How do I write htaccess?

I would like to redirect from Sakura Internet's initial domain (specific directory only) to its own domain, but the following writing method does not work.Could someone tell me the installation location and how to write it?I just started operating it, but it is inconvenient to access the initial domain. Sakura's "Multidomain Destination Folder" has already been registered in shoki2/, so you can access your own domain.
Thank you for your cooperation.

Initial domain: abcd.sakura.ne.jp/
Initial Directory: abcd.sakura.ne.jp/shoki2/ 

Redirect destination (proprietary domain): example.com/

htaccess Location: I installed the following in the directory of shoki2/, but none of them worked.

RewriteCond%{HTTP_HOST}^(abcd\.sakura\.ne.jp/shoki2/)(:80)?
RewriteRule^(.*)http://example.com/$1 [R=301,L]

RewriteEngine On
RewriteCon%{HTTP_HOST}^(www\.)?abcd\.sakura\.ne\.jp/shoki2/$[NC]
RewriteRule.*http://example.com/% {REQUEST_URI} [R=301,L]

I don't know how to write specific directories.
Thank you for your cooperation.

Thank you for your reply below.I was able to transfer it.

.htaccess

2022-09-30 20:44

1 Answers

http://abcd.sakura.ne.jp/shoki2/hogehoge/

http://example.com/hogehoge/

Do you mean to redirect them as shown in ?

HTTP_HOST does not have a path, so that RewriteCond does not match.

If you want to redirect to a particular directory, you might want to place .htaccess in that particular directory.

shoki2/ directory .htaccess

RewriteEngine on
RewriteCon%{HTTP_HOST}^abcd\.sakura\.ne\.jp(:80)?$
RewriteRule^(.*)$http://example.com/$1 [R=301,L]

If for some reason .htaccess cannot be placed in the shoki2/ directory, specify the directory name in RewriteRule.

Document Route .htaccess

RewriteEngine on
RewriteCon%{HTTP_HOST}^abcd\.sakura\.ne\.jp(:80)?$
RewriteRule^shoki2/(.*)$http://example.com/$1 [R=301,L]


2022-09-30 20:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.