1

URL から index.php を削除して、Web サイトの URL をよりクリーン (および SEO フレンドリー) にしようとしましたが、予期しない結果が発生しました。これが私の .htaccess ファイルです。

<IfModule mod_rewrite.c>
<IfModule mod_rewrite.c>


    RewriteEngine On
    RewriteBase /

    ### Canonicalize codeigniter URLs


    RewriteRule ^(site(/index)?|index(\.php)?)/?$ / [L,R=301]
    RewriteRule ^(.*)/index/?$ $1 [L,R=301]

    # Removes trailing slashes (prevents SEO duplicate content issues)
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)/$ $1 [L,R=301]

</IfModule>

<IfModule !mod_rewrite.c>

    # Without mod_rewrite, route 404's to the front controller
    ErrorDocument 404 /index.php

</IfModule>  

コントローラーは :site.php です。

4

1 に答える 1

0

Three Things To Try:

  1. Did you remove index.php from the config.php file

  2. Have you tried using the htacces provided from CI directly?

  3. Set $config['uri_protocol'] to be 'AUTO'; OR QUERY_STRING

straight from the user guide:

http://codeigniter.com/user_guide/general/urls.html

Removing the index.php file

By default, the index.php file will be included in your URLs:

example.com/index.php/news/article/my_article

You can easily remove this file by using a .htaccess file with some simple rules. Here is an example of such a file, using the "negative" method in which everything is redirected except the specified items:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

In the above example, any HTTP request other than those for index.php, images, and robots.txt is treated as a request for your index.php file.

于 2012-05-21T15:40:58.533 に答える