質問: joomlaはindex.phpを削除します-ホームページ.htaccessにリダイレクトします 以下は、私の.htaccess、sef、およびグローバル設定でuse rewriting enableです。しかし、私はまだ2つのurlで自分のホームページにアクセスできます。たとえば、www.example.comおよびwww.example.com/index.php。私は何か間違ったことをしていますか? index.phpから削除する方法を教えてください## # @package joomla # @copyright copyright (c) 2005 - 2014 open source matters. all rights reserved. # @license gnu general public license version 2 or later; see license.txt ## ## # read this completely if you choose to use this file! # # the line just below this section: 'options +followsymlinks' may cause problems # with some server configurations. it is required for use of mod_rewrite, but may already # be set by your server administrator in a way that dissallows changing it in # your .htaccess file. if using it causes your server to error out, comment it out (add # to # beginning of line), reload your site in your browser and test your sef url's. if they work, # it has been set by your server administrator and you do not need it set here. ## ## can be commented out if causes errors, see notes above. options +followsymlinks ## mod_rewrite in use. rewriteengine on rewritecond %{http_host} ^mysitename.com [nc] rewriterule (.*) http://www.mysitename.com/$1 [l,r=301] # ## begin - rewrite rules to block out some common exploits. # if you experience problems on your site block out the operations listed below # this attempts to block the most common type of exploit `attempts` to joomla! # # block out any script trying to base64_encode data within the url. rewritecond %{query_string} base64_encode[^(]*\([^)]*\) [or] # block out any script that includes a <script> tag in url. rewritecond %{query_string} (<|%3c)([^s]*s)+cript.*(>|%3e) [nc,or] # block out any script trying to set a php globals variable via url. rewritecond %{query_string} globals(=|\[|\%[0-9a-z]{0,2}) [or] # block out any script trying to modify a _request variable via url. rewritecond %{query_string} _request(=|\[|\%[0-9a-z]{0,2}) # return 403 forbidden header and show the content of the root homepage rewriterule .* index.php [f] # ## end - rewrite rules to block out some common exploits. ## begin - custom redirects # # if you need to redirect some pages, or set a canonical non-www to # www redirect (or vice versa), place that code here. ensure those # redirects use the correct rewriterule syntax and the [r=301,l] flags. # ## end - custom redirects ## # uncomment following line if your webserver's url # is not directly related to physical file paths. # update your joomla! directory (just / for root). ## # rewritebase / ## begin - joomla! core sef section. # rewriterule .* - [e=http_authorization:%{http:authorization}] # # if the requested path and file is not /index.php and the request # has not already been internally rewritten to the index.php script rewritecond %{request_uri} !^/index\.php # and the request is for something within the component folder, # or for the site root, or for an extensionless url, or the # requested url ends with one of the listed extensions rewritecond %{request_uri} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [nc] # and the requested path and file doesn't directly match a physical file rewritecond %{request_filename} !-f # and the requested path and file doesn't directly match a physical folder rewritecond %{request_filename} !-d # internally rewrite the request to the index.php script rewriterule .* index.php [l] # ## end - joomla! core sef section.
回答: 以下のようなものを試すことができます:# redirect index.php to root rewritecond %{the_request} !^post rewritecond %{the_request} ^[a-z]{3,9}\ /index\.php\ http/ rewritecond %{server_port}>s ^(443>(s)|[0-9]+>s)$ rewriterule ^index\.php$ http%2://yoursite.com/ [r=301,l] 更新:以下の.htaccessファイルの内容を試してください。また、セキュリティを強化するためのいくつかの追加ルールも含まれています。必ずすべての行を読み、必要に応じて調整してください。メモ-手順: 古いhtaccessファイルのコピーを作成し、名前をhtaccess-old.txtに変更して、サーバーに保存します。 ここの内容をアクティブな.htaccessファイルに貼り付けて保存します。 なんらかの理由でサーバーから500エラーが発生した場合-古いhtaccessに戻して、ここで報告してください。 htaccessファイルが機能するためには、全員が同じページにいることを確認するために、joomlaルートのデフォルトのhtaccess.txtファイルから.htaccessに名前を変更する必要があります。 また、joomla global configurationでrl rewritingを有効にする必要があります。# @package joomla # @copyright copyright (c) 2005 - 2014 open source matters. all rights reserved. # @license gnu general public license version 2 or later; see license.txt ## ## # read this completely if you choose to use this file! # # the line just below this section: 'options +followsymlinks' may cause problems # with some server configurations. it is required for use of mod_rewrite, but may already # be set by your server administrator in a way that dissallows changing it in # your .htaccess file. if using it causes your server to error out, comment it out (add # to # beginning of line), reload your site in your browser and test your sef url's. if they work, # it has been set by your server administrator and you do not need it set here. ## ##### begin - rewriteengine enabled ### 1. --- can be commented out if causes errors, see notes above. --- rewriteengine on ##### end - rewriteengine enabled ##### begin - rewritebase set ### 1. ---------- make sure you have enabled the rewrite settings in global configuration in joomla admin ------- ### 2. ---------- if your site is not at the root, you need to specify the folder e.g. rewritebase /yoursiterootfolder ------- rewritebase / ##### end - rewritebase set ##### begin - file execution order ### 1. ----------this is will make sure that index.php is loaded first than index.html ------- directoryindex index.php index.html ##### end - file execution order -- ##### begin - block directory listings ### 1. ----------this is an extra security measure to disable directory listings------- indexignore * options -indexes ##### end - no directory listings ##### begin - redirect index.php to root ### 1. ---------- make sure you add your site url at the rewrite rule ------- rewritecond %{the_request} !^post rewritecond %{the_request} ^[a-z]{3,9}\ /index\.php\ http/ rewritecond %{server_port}>s ^(443>(s)|[0-9]+>s)$ rewriterule ^index\.php$ http%2://yoursite.com/ [r=301,l] ##### end - redirect index.php to root ##### begin - redirect non-www to www rewritecond %{http_host} !^www\. [nc] rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l] ##### end - redirect non-www to www ## begin - rewrite rules to block out some common exploits. # if you experience problems on your site block out the operations listed below # this attempts to block the most common type of exploit `attempts` to joomla! # # block out any script trying to base64_encode data within the url. rewritecond %{query_string} base64_encode[^(]*\([^)]*\) [or] # block out any script that includes a <script> tag in url. rewritecond %{query_string} (<|%3c)([^s]*s)+cript.*(>|%3e) [nc,or] # block out any script trying to set a php globals variable via url. rewritecond %{query_string} globals(=|\[|\%[0-9a-z]{0,2}) [or] # block out any script trying to modify a _request variable via url. rewritecond %{query_string} _request(=|\[|\%[0-9a-z]{0,2}) # return 403 forbidden header and show the content of the root homepage rewriterule .* index.php [f] # ## end - rewrite rules to block out some common exploits. ## begin - server protection : disallow access to htaccess.txt, php.ini and configuration.php-dist ### 1. --- extra security measure, to prevent access to these essential files --- rewriterule ^(htaccess\.txt|configuration\.php-dist|php\.ini)$ - [f] ##### end - server protection ## begin - joomla! core sef section. # rewriterule .* - [e=http_authorization:%{http:authorization}] # # if the requested path and file is not /index.php and the request # has not already been internally rewritten to the index.php script rewritecond %{request_uri} !^/index\.php # and the requested path and file doesn't directly match a physical file rewritecond %{request_filename} !-f # and the requested path and file doesn't directly match a physical folder rewritecond %{request_filename} !-d # internally rewrite the request to the index.php script rewriterule .* index.php [l] # ## end - joomla! core sef section.