それを達成した後、私は(ホスティング会社のgodaddyのために)index.php?
自分のウェブサイトのURLから削除するのに苦労しました. その後、何人かの
ユーザー
が私のウェブサイトに古いURL ( .
インターネットを少し検索しましたが、問題の背後にある理由は、同じページ要求に含まれているが
含まれていない(推奨)すべてのURL
からリダイレクトする必要があるためだと思います。index.php?/
index.php?
index.php?/
example.com
index.php?/
例: リクエストするとorexample.com/index.php?/site/category/etc
につながります (推奨される方法)。
他の URL も同じように扱われます。example.com
example.com/site/category/etc
これが私の現在の.htaccess
ファイルです(この問題に関連するものは何もありません):
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
更新:
php ソリューションを試す:(Robin Castlin の功績)
(回答に基づいて) フックを使用してみましたが、機能しませんでした! 私は構成hooks
から有効になり、URL
ヘルパーは自動ロードされます。
この関数は内部にありapplication/hooks/MY_hooks.php
ます:
function redirectToNewURL(){
if(preg_match('~/index.php?/~', $_SERVER['REQUEST_URI'])) {//check if the URL has index.php
header('Location: '.current_url(), true, 301); //redirect
exit;
}
}
これは私がフックを設定する方法です:
この単純な配列を置きます
:application/config/hooks.php
$hook['pre_controller'] = array(
'class' => '',
'function' => 'redirectToNewURL',
'filename' => 'MY_hooks.php',
'filepath' => 'hooks'
);
結局、結果が出ませんでした。