简体   繁体   中英

Conflict with WP and .htaccess mod_rewrite?

I've been struggling for days trying to find a way to allow certain redirects in my WP site without them showing on the address bar.

It should work like this: if the user types mydomain.com/abc he is redirected to mydomain.com/xyz but in his browser the address bar still displays mydomain.com/abc

Now that sounds simple enough but I can't make it work for the life of me. I thought the canonical_redirect function in WP was causing some kind of conflict, so I disabled it, but it still won't work.

I've tried this code in .htaccess (and several variants)

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^en-uk(/.*)?$ /en$1 [L]

The redirect works fine, but the URL in the address bar changes to the new page, which is not what I want.

Any ideas?

Try this

<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteBase /xyz/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /xyz/index.php [L]

</IfModule>

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