重写我的 WordPress 网址以成为旧版网址
出于合理的原因,我需要重写我的 WordPress“页面”的所有 url,以将其用作旧版 url。
例如,当有人输入
www.mysite.com/contact_us
时,我想将我的 WordPress 上的页面提供为“/contact-us/”,但保持 URL 完整为 contact_us
当前我的 WordPress永久链接已设置为自定义结构,这在我的 .htaccess 中提供了以下内容:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
有人可以告诉我如何添加规则来重写上述内容。我有大量的网址要做,但一个例子在这里会有很大的帮助。谢谢。
我尝试添加
ReWriteRule ^contact_us$ /contact-us/
,但我只是在 /contact_us 网址上收到 404 错误。
For a valid reason, I need to rewrite all the urls of my wordpress 'pages' to work as legacy urls.
So for example, when someone enters
www.mysite.com/contact_us
I want to serve up the page thats sitting on my wordpress as `/contact-us/ but keep the url intact as contact_us
Currently my wordpress permalinks have been set to custom structure, which gives me the following in my .htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Can someone please show me how to add in a rule to rewrite the above. I have loads of urls to do but an example will be a huge help here. Thanks.
I've tried adding
ReWriteRule ^contact_us$ /contact-us/
, but i just get a 404 on the /contact_us url.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我已经怀疑了:我刚刚将其重写为原始页面 url。我通过关闭永久链接重写或将鼠标悬停在特定页面的视图锚点上来找到原始 url,以获得正确的 page_id 值。
Ok I've sussed it: I have just rewritten it to the raw page url. I found the raw url by either turning off permalink rewriting, or by hovering over the view anchor for the specific page, in order to obtain the correct page_id value.