我正在嘗試 301 重定向Index.php到另一個 URL
這是我的 htaccess 代碼
Options FollowSymLinks
RewriteEngine on
Redirect 301 /index.php /en1
RewriteRule en1 index.php [NC]
例如,我的域是
www.mysite.com
我希望這可以作為
www.mysite.com/en1
在 URL 欄中,它顯示新 URL,但瀏覽器顯示
The page isn’t redirecting properly
如何修復此 301 重定向?
uj5u.com熱心網友回復:
使用您顯示的示例,請嘗試遵循 .htaccess 規則檔案。請確保在測驗您的 URL 之前清除您的瀏覽器快取。
Options FollowSymLinks
RewriteEngine ON
##Implement http ---> https rules here.
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
##External redirect rules here.
RewriteRule ^/?$ /en5 [R=301,L]
##Internal rewrite to index.php rules here.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^en5/?$ index.php [L]
或者,如果您想撰寫一個通用規則來將每個不存在的檔案重寫為 index.php,請嘗試以下操作:
Options FollowSymLinks
RewriteEngine ON
##Implement http ---> https rules here.
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
##External redirect rules here.
RewriteRule ^/?$ /en5 [R=301,L]
##Internal rewrite to index.php rules here.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
注意:一次只使用一個規則集。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/518152.html
下一篇:SQL2008中的回圈
