简体   繁体   English

使用RewriteRules和404进行301重定向

[英]301 Redirect with RewriteRules and 404

I'm using .htaccess setup to rewrite my urls on domain.com from domain.com/index.php?id=1&... to seo friendly urls: www.domain.com/seo-friendly-url/23408425 , this way: 我正在使用.htaccess设置将domain.com上的网址从domain.com/index.php?id=1&...重写为seo友好网址:www.domain.com/seo-friendly-url/23408425,方式:

ErrorDocument 404 /404.php
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT} !-f
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
RewriteRule !\.(js|bmp|txt|ico|gif|jpg|png|css|html|htm|swf|flv|xml|bat|ttf|php|mp3|doc|docx|pdf|xls|xlsx|dwg|zip|rar|csv)$ index.php [QSA,L,NC]
Redirect 301 old-seo-url http://www.domain.com/seo-friendly-url/13148934300

After migration from a non-cms site I'm trying to 301 redirect an old website's link: http://www.domain.com/old-seo-url 从非cms网站迁移后,我正尝试301重定向旧网站的链接: http : //www.domain.com/old-seo-url
to my structure: http://www.domain.com/seo-friendly-url/13148934300 我的结构: http : //www.domain.com/seo-friendly-url/13148934300

, but can't find the right way. ,但找不到正确的方法。 The standard 301 redirects are not doing anything. 标准301重定向没有执行任何操作。 Any tips are welcome. 欢迎任何提示。 Thank you 谢谢

:) found an aswer right now via stackowerflow suggestions, after 3 days of trying ... :)经过3天的尝试后,现在通过stackowerflow建议找到了一个错误的...

Redirect 301 /old-seo-url http://www.domain.com/seo-friendly-url/13148934300

RewriteEngine on
RewriteCond %{DOCUMENT_ROOT} !-f
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
RewriteRule !\.(js|bmp|txt|ico|gif|jpg|png|css|html|htm|swf|flv|xml|bat|ttf|php|mp3|doc|docx|pdf|xls|xlsx|dwg|zip|rar|csv)$ index.php [QSA,L,NC]

ErrorDocument 404 /404.php

but I still welcome any improvements to my solution. 但我仍然欢迎对解决方案进行任何改进。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM