![](/img/trans.png)
[英]domain subfolder redirect to domain using .htaccess in wordpress
[英]Point add-on domain to a subfolder and redirect direct access to that subfolder to add-on domain using .htaccess
我有一個網站example.com/main
和另一個site example2.com.
我已成立了一個附加域example2.com
這顯示了文件main
子文件夾example.com
域。 我想要的是,當用戶轉到example2.com
,他們會在example2.com
上example2.com
而他們看到的是example.com/main
文件。 因此,如果他們訪問其他文件(例如main/contact.php
,則顯示為example2.com/contact.php
。
我已經成功完成了上面在cPanel附加頁面中提到的內容。
我的問題:
我想要這樣,以便當用戶直接訪問example.com/main
,我希望他們被重定向到example2.com
,然后查看main
子文件夾。 我沒有運氣,因為我一直陷入困境。
執行Redirect 301 / http://example2.com/
不起作用。
謝謝。
您可以使用:
RewriteCond %{HTTP_HOST} example\.com$ [NC]
RewriteCond %{THE_REQUEST} \s/+main[\s/?] [NC]
RewriteRule ^main(/.*)?$ http://example2.com$1 [NC,R=301,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.