/ / .htaccess - .htaccessを使用してindex.phpリクエストをhttp:// localhost / website /にリダイレクトし、mod-rewrite

index.phpリクエストをhttp:// localhost / website /にリダイレクトする.htaccess - .htaccess、mod-rewrite

.htaccessの設定にまだ慣れていないので、助けてください。

index.phpへのリンクがありますが、index.phpを自分のURLに表示したくない

eg.
http://localhost/website/index.php

私はそれがあるルートフォルダにリダイレクトされるようにしたい

http://localhost/website/

だから私は答えを探してみましたが、これが私がこれまでに得たものです。

RewriteEngine on

Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://localhost/website/$1 [R=301,L]

今すぐ私のローカルWebサイトで[ホーム]をクリックしようとすると

http://localhost/website

それはこれにリダイレクトされています -

http://localhost/Applications/XAMPP/xamppfiles/htdocs/website/localhost/website/

何が起こっているのか説明できますか?

回答:

回答№1は0

これを試しましたか

RewriteRule ^(.*)$ /index.php/$1 [L]

回答№2の場合は0

.htaccessを使って行った変更は、ページを更新してもすぐには有効になりません。効果を確認するためにキャッシュをクリアするのにしばらく時間がかかりました。私は私の質問に対して異なるアプローチを試みました:

Options +FollowSymLinks
RewriteEngine on

#RewriteCond %{THE_REQUEST} ^.*/index.php
#RewriteRule ^(.*)index.php$ http://localhost/website/$1 [R=301,L]

#RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /?(.*)/index.php
#RewriteRule ^ /%1 [L,R=301]

#RewriteRule ^(.*)$ /index.php/$1 [L]

#の行は私の問題を解決できなかったその理由は、キャッシュがクリアされていないためです。 以下のこの行は私の問題を解決したが、実際に結果を見る前に私のキャッシュをクリアするのに5回かかった。

RewriteRule ^index.php(.*)$ http://localhost/website/$1 [R=301,NC]

私はそれを得た htaccess generator