我正在使用wordpress开发一个网站,我正在尝试编写一个简单的重写规则(所有这些文档似乎都很简单)。
我需要将http://www.mysite.com/fitness/wp-content/themes/fitness/favorites.php
更改为http://www.mysite.com/fitness/favorites
。 健康 是我的主目录。
我在 .htaccess 文件中尝试了以下模式,但它们都抛出404错误:
1. RewriteRule ^favorites$ /fitness/wp-content/themes/fitness/favorites.php
2. RewriteRule ^/favorites/$ /fitness/wp-content/themes/fitness/favorites.php
3. RewriteRule ^favorite\.php$ - [L]
RewriteRule . /fitness/wp-content/themes/fitness/favorites.php [L]
我做错了什么?
答案 0 :(得分:0)
试试这段代码。这样可以简单地将旧网址重定向到新网址。
Options +FollowSymlinks
RewriteEngine on
rewriterule ^fitness/wp-content/themes/fitness/favorites.php(.*)$ http://www.mysite.com/fitness/favorites$1 [r=301,nc]