admin管理员组文章数量:1130349
Situation
- I have standard hosting in OVH (not VPS) and I'm able to set many websites on it in a different subdirectories,
- I would like to install 2 instances of Wordpress - first in directory
/Aand secend in directory/B - I would like "A" to use
domainand "B" to usesubdomain.domain
Question
- In that case need I use standard
.htaccessconfiguration for Wordpress on a single domain in each Wordpress directory or have I to use special configuration for subdomain in each Wordpress directory ?
Domain
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
SubDomain
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
- or maybe should I use subdirectory version of
.httaccess?
SubFolder
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
Situation
- I have standard hosting in OVH (not VPS) and I'm able to set many websites on it in a different subdirectories,
- I would like to install 2 instances of Wordpress - first in directory
/Aand secend in directory/B - I would like "A" to use
domainand "B" to usesubdomain.domain
Question
- In that case need I use standard
.htaccessconfiguration for Wordpress on a single domain in each Wordpress directory or have I to use special configuration for subdomain in each Wordpress directory ?
Domain
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
SubDomain
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
- or maybe should I use subdirectory version of
.httaccess?
SubFolder
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
Share
Improve this question
edited Feb 9, 2017 at 7:42
DDos Schwagins
asked Feb 3, 2017 at 10:29
DDos SchwaginsDDos Schwagins
1911 gold badge1 silver badge8 bronze badges
1 Answer
Reset to default 6My suggestion is: use the same standard .htaccess configuration for Wordpress on a single domain in each Wordpress directory.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Along with it, add a small CODE to make sure users are redirected to the correct domain in case they reach to that subdirectory using another domain:
RewriteCond %{HTTP_HOST} !^domain\$
RewriteRule ^(.*)$ "https://domain/$1" [R=301,L]
After that, your .htaccess for domain will be like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^domain\$
RewriteRule ^(.*)$ "https://domain/$1" [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
and for subdomain.domain, it'll be like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^subdomain\.domain\$
RewriteRule ^(.*)$ "https://subdomain.domain/$1" [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Reasons:
Using standard CODE is recommended because it's easier to maintain & debug, as it's same everywhere.
The extra two line are recommended mainly for
SEO. Without them, one of your domain may be accessible using another domain. That may raise some duplicate content question.
Situation
- I have standard hosting in OVH (not VPS) and I'm able to set many websites on it in a different subdirectories,
- I would like to install 2 instances of Wordpress - first in directory
/Aand secend in directory/B - I would like "A" to use
domainand "B" to usesubdomain.domain
Question
- In that case need I use standard
.htaccessconfiguration for Wordpress on a single domain in each Wordpress directory or have I to use special configuration for subdomain in each Wordpress directory ?
Domain
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
SubDomain
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
- or maybe should I use subdirectory version of
.httaccess?
SubFolder
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
Situation
- I have standard hosting in OVH (not VPS) and I'm able to set many websites on it in a different subdirectories,
- I would like to install 2 instances of Wordpress - first in directory
/Aand secend in directory/B - I would like "A" to use
domainand "B" to usesubdomain.domain
Question
- In that case need I use standard
.htaccessconfiguration for Wordpress on a single domain in each Wordpress directory or have I to use special configuration for subdomain in each Wordpress directory ?
Domain
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
SubDomain
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
- or maybe should I use subdirectory version of
.httaccess?
SubFolder
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
Share
Improve this question
edited Feb 9, 2017 at 7:42
DDos Schwagins
asked Feb 3, 2017 at 10:29
DDos SchwaginsDDos Schwagins
1911 gold badge1 silver badge8 bronze badges
1 Answer
Reset to default 6My suggestion is: use the same standard .htaccess configuration for Wordpress on a single domain in each Wordpress directory.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Along with it, add a small CODE to make sure users are redirected to the correct domain in case they reach to that subdirectory using another domain:
RewriteCond %{HTTP_HOST} !^domain\$
RewriteRule ^(.*)$ "https://domain/$1" [R=301,L]
After that, your .htaccess for domain will be like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^domain\$
RewriteRule ^(.*)$ "https://domain/$1" [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
and for subdomain.domain, it'll be like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^subdomain\.domain\$
RewriteRule ^(.*)$ "https://subdomain.domain/$1" [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Reasons:
Using standard CODE is recommended because it's easier to maintain & debug, as it's same everywhere.
The extra two line are recommended mainly for
SEO. Without them, one of your domain may be accessible using another domain. That may raise some duplicate content question.
本文标签: Htaccess for Wordpess set on single subdomain
版权声明:本文标题:Htaccess for Wordpess set on single subdomain 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749151061a2323826.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论