0

我的文件结构如下:

application
public_html
       .htaccess
       index

应用程序/config/config.php

       here i have set blank my base_url and index page

.htaccess

DirectoryIndex index.php
RewriteEngine on                       
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA] 

但如果我使用 index.php 她我仍然在httpd.conf上使用虚拟主机

<VirtualHost *:80>

    ServerAdmin webmaster@dab
    DocumentRoot "c:\wamp\www\dab\public_html"

    ServerName dab
    ServerAlias www.dab
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-acces.log" common

    <directory "c:\wamp\www\dab\public_html">
        Options FollowSymlinks
        AllowOverride None
        Order Deny,Allow
        Deny from all
        Allow from 127.0.0.1
    </directory>
</VirtualHost>

在 url 上不使用 index.php 的解决方案是什么

提前致谢

4

2 回答 2

1

在 application/config/config.php 文件中找到以下行

$config['index_page'] = 'index.php';

将变量设置为空,如下所示。

$config['index_page'] = '';

就是这样,它对我有用。

如果它不起作用,请尝试用这些参数('AUTO'、'PATH_INFO'、'QUERY_STRING'、'REQUEST_URI'和'ORIG_PATH_INFO')一一替换以下变量

$config['uri_protocol'] = 'AUTO';
于 2013-05-01T09:17:49.563 回答
1

确保你在你的 apache conf 中启用了 mod_rewrite 模块,然后尝试一个看起来更像这样的 .htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>
于 2013-05-01T09:18:58.050 回答