简体   繁体   English

与WP和.htaccess mod_rewrite冲突?

[英]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. 数天来,我一直在努力寻找一种方法,以允许在我的WP网站中进行某些重定向,而不在地址栏中显示这些重定向。

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 它应该像这样工作:如果用户键入mydomain.com/abc他将被重定向到mydomain.com/xyz但是在他的浏览器中,地址栏仍然显示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. 我以为WP中的canonical_redirect函数会引起某种冲突,因此我将其禁用,但仍然无法正常工作。

I've tried this code in .htaccess (and several variants) 我已经在.htaccess中尝试了此代码(以及几种变体)

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. 重定向工作正常,但是地址栏中的URL更改为新页面,这不是我想要的。

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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