2017-03-12 3 views
1

PHP & MySQLを使用してショッピングカートを構築しようとしています。今、私は製品詳細ページを作成中です。だから、これは(ルートフォルダにあります)、私は私のhtaccessファイルを設定する方法です:私のhtaccessは正しいですか?

Options +FollowSymLinks 
Options -Indexes 
DirectoryIndex index.php 
<IfModule mod_rewrite.c> 
    RewriteEngine on 
    RewriteCond $1 !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico) 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^([^\.]+)$ $1.php [NC,L] 
</IfModule> 
<IfModule !mod_rewrite.c> 
    ErrorDocument 404 /index.php 
</IfModule> 

私の問題は、index.phpのが含まれている場合、私は唯一の特定のページにアクセスすることができます。たとえば、http://localhost/thegamingplace/products/details/1は「見つかりません」というエラーを表示しますが、http://localhost/thegamingplace/index.php/products/details/1が機能します。

誰かが私のhtaccessを見て、私が間違っていることを教えてもらえますか?

+0

もちろん、あなたの書き換えルールは、 '/ thegamingplace/products/details/1'を'/thegamingplace/products/details/1.php'に書き換えます。私の推測では 'index.php/$ 1'代わりに – apokryfos

+0

それは、まだ動作しませんでしたか? –

答えて

0

はこれを試してみてください:

RewriteCond %{REQUEST_URI} !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^\.]+)$ index.php/$1 [NC,L] 

http://htaccess.mwl.be/

で試験した場合、それはあなたがmod_rewriteをインストールして有効にしていることを確認して動作しない場合はそれが動作します。

+0

まだ動作しません。どうやら問題はindex.phpがサイトのすべてのページで削除されないことです。たとえば、http:// localhost:thegamingplace /に行くと、index.phpを使わずに動作します。しかし、製品ページ(http:// localhost:thegamingplace/products/details/1)に行くと動作しません。私のエラーメッセージ:要求されたURL/thegamingplace/products/details/1がこのサーバー上に見つかりませんでした。 –

+0

実際、mod_rewriteを有効にしてこれを修正しました。ありがとう! –

関連する問題