Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 奇怪的重写行为_Wordpress_Apache_Mod Rewrite - Fatal编程技术网

Wordpress 奇怪的重写行为

Wordpress 奇怪的重写行为,wordpress,apache,mod-rewrite,Wordpress,Apache,Mod Rewrite,我正在一个子目录中运行Wordpress(和buddypress插件): mydomain.com/mysubdomain/ 我的修改如下: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /mysubdomain/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d R

我正在一个子目录中运行Wordpress(和buddypress插件):

mydomain.com/mysubdomain/
我的修改如下:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mysubdomain/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mysubdomain/index.php [L]
</IfModule>
这将重写到页面-但是,这将显示Wordpress的404页面未找到错误。(浏览器中的URL是正确的:)

由于Wordpress 404页面显示,这表明问题在于Wordpress的modrewrite与newpage.html重定向冲突

非常感谢您的帮助/建议


谢谢

您的规则似乎与您描述的不符:

RewriteCond %{HTTP_HOST} ^([a-z0-9-]+).mydomain.com [NC]
RewriteRule ^newpage\.html$ http://mydomain.com/mysubdomain/about-us [NC,L]
这会将浏览器重定向到与似乎正在发生的事情不一致的位置。问题是,如果您只是重写URI(对此不确定,这只是猜测),wordpress控制器可能无法正确处理请求,因此您可能需要重写为未重写的URI:

RewriteRule ^newpage\.html$ /mysubdomain/?page=2 [NC,L]

谢谢你的回复,乔恩。听起来你不能重定向到一个“漂亮”的URL,所以你应该重定向到?page=2,对吗?@user663561在上一条规则中没有重定向。浏览器的地址栏仍会显示
mydomain.com/newpage.html
,但提供的是
/mysubdomain/?page=2
。它是内部重写的。如果浏览器从未看到它,那么没有理由让它成为一个漂亮的URL。嗨,Jon,“…问题是,如果您只是重写URI,wordpress控制器可能无法正确处理请求,因此您可能需要重写为未重写的URI…”这似乎就是正在发生的情况。重定向到未重写的URI似乎有效。
RewriteRule ^newpage\.html$ /mysubdomain/?page=2 [NC,L]