dsm13698679318
2014-09-23 20:06 阅读 76
已采纳

Kohana在此服务器上找不到请求的URL / home

I am getting this error from a red hat apache environment which is running php with a Kohana application. This application was migrated from a wamp installation where it was functioning.

Currently if I hit the following URL I get a 404 error

http://server/home

But if I hit this the page renders

http://server/index.php/home

I assume this has to do with my .htaccess files, but I have been unable to resolve the issue.

Below is the .htaccess file found in apache/htdocs where my application resides

  # Options +Indexes +FollowSymLinks

# Turn on URL rewriting
RewriteEngine On

# Installation directory

# production site is /commerical_production/kohana
# production resite site is below
# RewriteBase /commerical_production/kohana/
# RewriteBase /wedding/kohana/
RewriteBase /




# production site is /commerical_production/kohana/index.php/demo
# DirectoryIndex /commerical_production/kohana/index.php/demo
#DirectoryIndex /hiton/kohana/index.php/welcome
# DirectoryIndex /wedding/kohana/index.php/home


# Protect hidden files from being viewed
#<Files .*>
#        Order Deny,Allow
#        Deny From All
#</Files>

# Protect application and system files from being viewed
#RewriteRule ^(?:application|modules|system) - [F,L]

# Allow any files or directories that exist to be displayed directly
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
#RewriteRule ^(.*)$ index.php/$1 [PT]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d


#RewriteCond %{HTTP_HOST} ^www\.trinity.localhost\.com [NC] 
#RewriteRule ^(.*)$ index.php?lang=it [NC,QSA] 
#RewriteCond %{HTTP_HOST} ^www\.hilton.localhost\.com [NC] 
#RewriteRule ^(.*)$ index.php?lang=en [NC,QSA] 

Below is the .htaccess file found within the application in apache/htdocs/MyApp

RewriteEngine On

# Installation directory
RewriteBase /

# Protect hidden files from being viewed
<Files .*>
        Order Deny,Allow
         Allow from all
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
~

Does anyone have a recomendation? I have the bootstrap.php set to

Kohana::init(array(
        'base_url'   => '/',
        'index_file' => FALSE,
));



Route::set('default', '(<controller>(/<action>(/<id>)))')
        ->defaults(array(
                'controller' => 'welcome',
                'action'     => 'index',
        ));

apache httpd.conf

    LoadModule authn_file_module modules/mod_authn_file.so
#LoadModule authn_dbm_module modules/mod_authn_dbm.so
#LoadModule authn_anon_module modules/mod_authn_anon.so
#LoadModule authn_dbd_module modules/mod_authn_dbd.so
#LoadModule authn_socache_module modules/mod_authn_socache.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
#LoadModule authz_dbm_module modules/mod_authz_dbm.so
#LoadModule authz_owner_module modules/mod_authz_owner.so
#LoadModule authz_dbd_module modules/mod_authz_dbd.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
#LoadModule auth_form_module modules/mod_auth_form.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule allowmethods_module modules/mod_allowmethods.so
#LoadModule file_cache_module modules/mod_file_cache.so
#LoadModule cache_module modules/mod_cache.so
#LoadModule cache_disk_module modules/mod_cache_disk.so
#LoadModule cache_socache_module modules/mod_cache_socache.so
#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
#LoadModule socache_dbm_module modules/mod_socache_dbm.so
#LoadModule socache_memcache_module modules/mod_socache_memcache.so
#LoadModule macro_module modules/mod_macro.so
#LoadModule dbd_module modules/mod_dbd.so
#LoadModule dumpio_module modules/mod_dumpio.so
#LoadModule buffer_module modules/mod_buffer.so
#LoadModule ratelimit_module modules/mod_ratelimit.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
#LoadModule ext_filter_module modules/mod_ext_filter.so
#LoadModule request_module modules/mod_request.so
#LoadModule include_module modules/mod_include.so
LoadModule filter_module modules/mod_filter.so
#LoadModule substitute_module modules/mod_substitute.so
#LoadModule sed_module modules/mod_sed.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
#LoadModule log_debug_module modules/mod_log_debug.so
#LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
#LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so
#LoadModule unique_id_module modules/mod_unique_id.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
#LoadModule remoteip_module modules/mod_remoteip.so
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
#LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
#LoadModule proxy_express_module modules/mod_proxy_express.so
#LoadModule session_module modules/mod_session.so
#LoadModule session_cookie_module modules/mod_session_cookie.so
#LoadModule session_dbd_module modules/mod_session_dbd.so
#LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
#LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
#LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
#LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
#LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so
LoadModule unixd_module modules/mod_unixd.so
#LoadModule dav_module modules/mod_dav.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
#LoadModule info_module modules/mod_info.so
#LoadModule cgid_module modules/mod_cgid.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
#LoadModule actions_module modules/mod_actions.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module        modules/libphp5.so



<IfModule mod_rewrite>
    RewriteEngine On
</IfModule>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

4条回答 默认 最新

  • 已采纳
    dtgr3392 dtgr3392 2014-09-30 14:46

    The issue was the apache httpd.conf was not configured correctly The directory which contained the web app needed the following.

    <Directory "/www/">
    Options All
    AllowOverride All
    Require all granted
    </Directory>
    
    点赞 评论 复制链接分享
  • dongwen3410 dongwen3410 2014-09-26 15:33

    Your .htaccess file is fine as it is. I have several Kohana apps with this exact .htaccess code.

    Have you checked that your Red Hat Apache has mod_rewrite module enabled?

    点赞 评论 复制链接分享
  • douxian7534 douxian7534 2014-09-29 14:14

    please try this .htaccess

    RewriteEngine On
    
    # Allow any files or directories that exist to be displayed directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # Rewrite all other URLs to index.php/URL
    RewriteRule .* index.php/$0 [PT,L]
    
    点赞 评论 复制链接分享
  • doupo1890 doupo1890 2018-01-06 11:19

    In My case I've just enable mod_rewrite at apache.

     sudo a2enmod rewrite 
    

    and than restart

    sudo systemctl restart apache2
    

    Check .htaccess rules.

    And make sure you have Controller_Welcome class, method in it.

    点赞 评论 复制链接分享

相关推荐