简体   繁体   English

htaccess:index.php的重定向

[英]htaccess: redirect of index.php

Sorry for not-very-clear title. 对不起,标题不是很清楚。

I'm using FatFreeFramework with his .htaccess: 我正在使用FatFreeFramework和他的.htaccess:

RewriteCond %{REQUEST_URI} \.ini$
    RewriteRule \.ini$ - [R=404]

    #RewriteCond %{REQUEST_URI} \.html?$
    #RewriteRule \.html?$ - [R=404]

    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php [L,QSA,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

Now, restyling an old site, I have in Google some url codified like 现在,重新设计旧网站,我在谷歌的一些网址编纂成像

www.example.com/index.php?ID=12

I would strip away that and redirect them to home page. 我会剥离它并将它们重定向到主页。

I don't know how write the rule, I did try to edit in this mode but without luck: 我不知道怎么写规则,我确实尝试在这种模式下编辑,但没有运气:

RewriteCond %{REQUEST_FILENAME} !-d
    Redirect 301 /index.php?ID=$1 index.php
    RewriteRule .* index.php [L,QSA,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

Right above this rules: 正好在这个规则之上:

RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L,QSA,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

Add this: 添加这个:

RewriteCond %{THE_REQUEST} \ /+index\.php\?ID=[0-9]
RewriteRule ^ / [L,R=301]

You can't match against the query string using mod_alias's Redirect directive. 您无法使用mod_alias的Redirect指令匹配查询字符串。

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

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