Redirect 301将脏URL重定向到干净URL

Redirect 301将脏URL重定向到干净URL,redirect,clean-urls,Redirect,Clean Urls,我真的需要一些帮助重定向脏网址到干净的 肮脏的URL:bioture.php?beast= 清洁URL:/神话生物/ 当前我的.htaccess如下所示: RewriteEngine On RewriteCond %{HTTP_HOST} ^mythicalcreatureslist.com [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{HTTP_HOST} ^

我真的需要一些帮助重定向脏网址到干净的

肮脏的URL:bioture.php?beast=

清洁URL:/神话生物/

当前我的.htaccess如下所示:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mythicalcreatureslist.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^www.mythbeasts.com [NC]
RewriteRule ^(.*)$ http://www.mythicalcreatureslist.com/$1 [L,R=301]

RewriteRule ^menu/([A-Za-z0-9-+]+)/?$  menu.php?menu=$1  [NC,L]
RewriteRule ^menu_two/([A-Za-z0-9-+]+)/?$  menu_two.php?menu=$1 [NC,L]

RewriteRule ^mythical-creature/([A-Za-z0-9-+\'%]+)/?$  creature.php?beast=$1  [NC,L]
这样做是为了让网站在浏览时显示干净的URL,这很好。但是,在URL栏中键入时,旧的脏URL不会重定向

例子:蒙古死亡蠕虫

我希望它重定向到:

这导致内容重复。我试过:

RewriteRule ^/mythical-creature/([A-Za-z0-9-+\'%]+)/?$  http://www.mythicalcreatureslist.com/creature.php?beast=$1 [R=301,NC,L]
但是,这样做的结果是导致脏的那个一直被使用

然后我把它翻转过来:

RewriteRule  ^creature.php?beast=([A-Za-z0-9-+\'%]+)/?$ http://www.mythicalcreatureslist.com/mythical-creature/$1  [R=301,NC,L]

但这只会在浏览时导致404,并且在地址栏中键入时仍然没有重定向旧的脏URL。

正则表达式与空查询参数值不匹配。将+翻转为*

RewriteRule ^/creature.php?beast=([A-Za-z0-9-+\'%]*)/?$ http:// www.mythicalcreatureslist.com/mythical-creature/$1 [R=301,NC,L]

请注意,添加了一个前导斜杠也

谢谢Kyle,但不幸的是,这并没有带来什么不同。浏览时仍会导致404,在地址栏中键入时不会重定向旧的脏url。@Egan7此url是否可以直接访问:蒙古语+死亡+蠕虫在404上看到了什么url?是否缺少前导斜杠?嗨,Kyle,404页面是我在数据库中找不到生物名称时设计的页面。生物名称来自GET函数(位于bioture.php?beast=或/mythical bioture/之前的部分)。代码:全局$sel_beast;if(isset($_GET[“beast”]){$sel_beast=$_GET[“beast”];}else{$sel_beast=”“;}if($sel_biost){}else{标题(“位置:找不到.html”);}