gpt4 book ai didi

.htaccess - 清理 URL - 将 301 从带问号的 URL 重定向到新 URL

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:31:09 24 4
gpt4 key购买 nike

原始网址:example.com?file=gallery&d=doc我想要:example.com/gallery.html

我的.htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
RewriteRule ^([^/]*)\.html$ /?file=$1&d=doc [L]

(从 url 中删除了 d=doc 因为不需要)

现在可以清理 URL,但我希望 301 重定向所有旧 URL (?file=example&d=doc)。任何人都可以帮我解决 .htaccces 问题?现在页面可从 example.com?file=gallery&d=docexample.com/gallery.html 获得,但应该来自 >example.com/gallery.html

最佳答案

试试这个:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.med-pro.pl$
RewriteRule ^(.*)$ http://med-pro.pl/$1 [R=301,L]

RewriteRule ^([^/]*)\.html$ /?plik=$1&d=doc&r=0 [L]

RewriteCond %{QUERY_STRING} ^plik=([^&]*)&d=doc$
RewriteRule .* %1.html? [L,NC,R=301]

关于.htaccess - 清理 URL - 将 301 从带问号的 URL 重定向到新 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11902803/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com