2013-08-31 108 views
0

我想将网址以 http://a_domain_name.com/2013/08/link_name/feed重定向到http://a_domain_name.com/link_name/feed。我是一名WordPress初学者,发现很难做到这一点。什么是最好的方法来做到这一点?在WordPress中重定向URL

我尝试使用安全的重定向插件与http://domain_name.com/%year%/%monthnum%/%postname%/feedhttp://domain_name.com/%postname%/feed但它不工作

+0

此资源是否有帮助? http://codex.wordpress.org/Using_Permalinks –

回答

2

有道

登录到WordPress管理面板,转到设置>永久链接页面。

从这里,选择倒数第二选项,即:

http://domain.com/blogname/blog/sample-post/


另外,你可以创建一个重定向文件。这涉及到对wordpress的一些攻击。如果你不喜欢wordpress & php,我不会推荐这款软件。要做到这一点,首先:

公开赛在管理面板的设置>永久链接页面:

在列表中选择(自定义)的最后一个选项,并输入是这样的:

/redirect.php?p=%post_id%&a=%author%&c=%category%

您还需要更改以下两个可选的形式:

类别基地

/redirect.php?c=

标签基地

/redirect.php?t=

现在,让我们创建一个重定向PHP文件。将此放在/ yourblogname /博客/

<?php 


$total=0; 

$string = 'http://www.yourdomain.com/'; 
$fetch = ''; 

if (isset($_GET['p'])&&!is_null($_GET['p'])) 
{ 
    $p = $_GET['p']; 
    if ($total ==0) { 
     $string.='?p='.$p;  
    } else { 
     $string.='&p='.$p; 
    } 
    $total++; 
} 
if (isset($_GET['t'])&&!is_null($_GET['t'])) 
{ 
    $t = str_replace('/','',$_GET['t']); 
    if ($total ==0) { 
     $string.='?tag='.$t; 
    } else { 
     $string.='&tag='.$t; 
    } 
    $total++; 
} 
if (isset($_GET['a'])&&!is_null($_GET['a'])) 
{ 
    $a = $_GET['a']; 
    if ($total ==0) { 
     $string.='?a='.$a; 
    } else { 
     $string.='&a='.$a; 
    } 
    $total++; 
} 
if (isset($_GET['s'])&&!is_null($_GET['s'])) 
{ 
    $s = $_GET['s']; 
    if ($total ==0) { 
     $string.='?s='.$s; 
    } else { 
     $string.='&s='.$s; 
    } 
    $total++; 
} 
if (isset($_GET['c'])&&!is_null($_GET['c'])) 
{ 
    $c = str_replace('/','',$_GET['c']); 
    if ($total ==0) { 
     $string.='?category_name='.$c; 
    } else {  
     $string.='&category_name='.$c; 
    } 
    $total++; 
} 



echo '<head><meta http-equiv="Refresh" content="0; URL='.$string.'">'; 
?> 
<style> 
html { 
    background:black; 
    color:white; 
} 
</style> 
</head> 
<body> 
<div id=cont> 
<p align=center><div style='font-size:72px;text-align:center;' ><?php echo "redirecting..."; ?></p></div> 
</div> 
</body> 

我们还没有完成。我们需要调整我们重定向到现在的页面...(的index.php)

if (!isset($_GET['p'])) { 
    if (!isset($_GET['category_name']) && !isset($_GET['tag']) && !isset($_GET['s']) && !isset($_GET['search'])) { 
      include('newhome.php'); //frontpage with no special redirect 
    } else { 
     include('listabbrposts.php'); //a list of abbreviated posts for browsing 
    } 
} else { 
    include('entry.php'); // a page with a single article 
} 

对于工作的例子,你可以看看我的页面,在这里我使用了这种方法:http://www.artfuladvection.com单击某个主题或标记从左侧看到重定向。

+0

我只是说,使用更长的方法会导致挫败感,并需要在多个文件中前进编辑。如果您是WordPress新手,最好使用预设永久链接模板之一。 – DrewP84