簡體   English   中英

有重寫規則時如何使用htacess進行重定向

[英]how to redirect with htacess when there are rewrite rules

我遇到以下問題:
我需要從/index.php重定向(301)到主頁,但是有重寫規則:

RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$  [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php

當我添加行時,存在重定向循環:

Redirect 301 /index.php http://example.com/

在不更改重寫規則的情況下該如何做? .htaccess對我來說還不夠清楚

規則如下:

RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php$ /$1 [L,R=301,NC,NE]

RewriteCond %{REQUEST_URI} (\.html?|\.php|/[^.]*)$  [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM