.htaccess 无SEO友好URL到SEO友好htaccess重定向
正在尝试301重定向.htaccess 无SEO友好URL到SEO友好htaccess重定向,.htaccess,redirect,url-redirection,.htaccess,Redirect,Url Redirection,正在尝试301重定向 www.mydomain.com/product.php?view=cat&category=t-shirts 到 请记住,我有多种不同的 product.php?view=cat&category=... 另外,旧的类别参考可能是X;但是,新的类别引用可能是Y。这是如何做到的?提前感谢你的帮助 下面是我的htaccess现在的样子 RewriteBase / # RewriteRule ^index\.php$ - [L] RewriteCond %{
www.mydomain.com/product.php?view=cat&category=t-shirts
到
请记住,我有多种不同的
product.php?view=cat&category=...
另外,旧的类别参考可能是X;但是,新的类别引用可能是Y。这是如何做到的?提前感谢你的帮助
下面是我的htaccess现在的样子
RewriteBase /
# RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/$ index\.php?pg=$1 [L]
RewriteRule ^([^/]*)/([^/]*)/$ index\.php?pg=$1&pid=$2 [L]
# RewriteRule . /index.php [L]
Redirect 301 /products.php?view=cat&mng=t-shirts http://www.mydomain.com/shirts/
Redirect 301 /products.php?view=cat&mng=shorts http://www.mydomain.com/pants/
Redirect 301 /products.php?view=cat&mng=jeans http://www.mydomain.com/pants/
不用说,我所有的“重定向301”都给出了404。我找不到任何逻辑可以避免“重写”和“重定向”之间的冲突。因此,我利用PHP301重定向将其保存在一个文件“products.php”中。在我的脚本中,我做了以下工作:
if (isset($_GET['mng']))
{
switch ($_GET['mng'])
{
case 't-shirts':
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.mydomain.com/shirts/");
break;
case 'shorts':
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.mydomain.com/pants/");
break;
case 'jeans':
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.mydomain.com/pants/");
break;
}
}
对不起,我没有评论我的php。感谢您的输入。也许这可以帮助您理解您所说的
还有,旧类别参考可能是X;但是,新的类别参考可能是Y
?不,这不是我要找的。我有一个旧网站,它的URL是www.mydomain.com/product.php?view=cat&category=t-shirts。新站点没有相同的结构。我已经更改了类别名称。例如,t恤现在是衬衫。
if (isset($_GET['mng']))
{
switch ($_GET['mng'])
{
case 't-shirts':
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.mydomain.com/shirts/");
break;
case 'shorts':
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.mydomain.com/pants/");
break;
case 'jeans':
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.mydomain.com/pants/");
break;
}
}