简体   繁体   中英

wordpress subfolder .htaccess redirect folder to domain root

I developed my dev site in a subfolder in my root directory, and I've now got my production version now in the root directory. I want to use the dev .htaccess to redirect to the root version of the site.

I've followed the instructions in this link: Redirect subdirectory of old domain to root folder of new domain via htaccess

this is my code:

RewriteEngine On
RewriteRule ^newsite/* http://www.mydomain.com/ [R=301,L]

At the moment it's just bringing up a 404 and staying at the same address without redirecting to the root.

I'm having trouble getting anything to respond at the moment, can anyone point me in the right direction please?

Thanks Frank

EDIT

So this is what it looks like with your suggestion Ravi, is this correct implementation?

<IfModule mod_rewrite.c>
RewriteRule ^newsite(/(.*))?$ http://www.mydomain.com/$2 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

This should work.

RewriteEngine On
RewriteBase /

RewriteRule ^newsite(/.*)?$ http://www.mydomain.com/ [R=301,L]

Would redirect /newsite , /newsite/ and /newsite/* (but not /newsitefolder ) to root / .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM