我有一个在wordpress上运行的网站,它的所有文件都位于我主机的public\\u html中。在其中,我创建了一个子域“phantomomaga”,并将另一个域重定向到该子域,使其成为“www.phantomaga.tk”,而不是“phantomaga.my domain.com”,为此,我向添加了一些代码。htaccess of my public\\u html as tellhere 让它像follow一样
代码
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
#Fix missing trailing slash character on folders.
RewriteRule ^([^.?]+[^.?/])$ $1/ [R,L]
#www.phantomomaga.tk and phantomomaga.tk will map to the folder {root}/phantomomaga/
RewriteCond %{HTTP:Host} ^(?:www\\.)?phantomomaga\\.tk$
RewriteCond %{REQUEST_URI} !^/phantomomaga/
RewriteRule ^(.*) phantomomaga/$1 [NC,L,NS]
问题由于此编辑,我能够实现我想要的,但由于我不知道的某些原因,现在我的子域的永久链接不起作用,并且如果我删除根文件夹中的wordpress安装,我会不断收到找不到的错误
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
从。htaccess子域工作正常,但根域出错,所以我认为问题在于。htaccess的根域或子域,我无法找出解决方案,即使在我google了它,所以请帮助。
最合适的回答,由SO网友:phantom.omaga 整理而成
我自己找到了解决方案,现在我将其张贴在这里,以便其他人可以从中受益
这个我重复了我的整个密码。htaccess具有以下功能,并且工作正常
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# ---------------------------------------
# BEGIN Domain to folder mapping
# pointing phantomomaga.tk to phantomomaga
ReWriteCond %{HTTP_HOST} phantomomaga.tk
ReWriteCond %{REQUEST_URI} !phantomomaga/
ReWriteRule ^(.*)$ phantomomaga/$1 [L]
# END Domain to folder mapping
# ---------------------------------------
# ---------------------------------------
# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
# ---------------------------------------
# ---------------------------------------
# BEGIN htaccess pretection
<Files .htaccess>
order allow,deny
deny from all
</Files>
# END htaccess pretection
# ---------------------------------------
</IfModule>
您可以对多个域执行此操作,如follow
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# ---------------------------------------
# BEGIN Domain to folder mapping
# pointing domain_1.com to folder_1
ReWriteCond %{HTTP_HOST} domain_1.com
ReWriteCond %{REQUEST_URI} !folder_1/
ReWriteRule ^(.*)$ folder_1/$1 [L]
# pointing domain_2.com to folder_2
ReWriteCond %{HTTP_HOST} domain_2.com
ReWriteCond %{REQUEST_URI} !folder_2/
ReWriteRule ^(.*)$ folder_2/$1 [L]
# END Domain to folder mapping
# ---------------------------------------
# ---------------------------------------
# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
# ---------------------------------------
# ---------------------------------------
# BEGIN htaccess pretection
<Files .htaccess>
order allow,deny
deny from all
</Files>
# END htaccess pretection
# ---------------------------------------
</IfModule>
来源:=
http://wordpress.org/support/topic/success-mapping-multiple-domains-to-different-folders-with-htaccess?replies=1#post-593544