简体   繁体   中英

htaccess wordpress redirect doesn't work properly

Wordpress is installed in sub-directory and I want to add redirect rule for whoever comes to http://example.com/folder/ to be redirected to http://example.com/custom-page/ and I was able to do this with:

Redirect /folder/ http://example.com/custom-page/

The problem is that I cannot access wp admin page because of this redirect. How can I exclude wp-admin from the rule above?

Thanks.

You can use RedirectMatch

 RedirectMatch ^/folder/((?!wp-admin).*)$ http://example.com/custom-page/$1

The pattern ((?!wp-admin)folder/.*) matches any request excluding /wp-admin and redirects it to the destination url

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