Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache服务器上的Php Codeigniter-内部页面不';行不通_Php_Apache_Codeigniter_Virtualhost - Fatal编程技术网

Apache服务器上的Php Codeigniter-内部页面不';行不通

Apache服务器上的Php Codeigniter-内部页面不';行不通,php,apache,codeigniter,virtualhost,Php,Apache,Codeigniter,Virtualhost,我有一个codeigniter php应用程序,它在我的本地机器(IIS)上运行得非常好,但是当我将它部署到LAMP服务器(Apache)上时,我只能访问http://:8080/company/,但不能访问该站点上的任何其他链接,例如http://:8080/company/help,http://:8080/company aboutus等 下面是我在远程服务器上针对Apache的virtualhost条目: <VirtualHost *:8080> Server

我有一个codeigniter php应用程序,它在我的本地机器(IIS)上运行得非常好,但是当我将它部署到LAMP服务器(Apache)上时,我只能访问
http://:8080/company/
,但不能访问该站点上的任何其他链接,例如
http://:8080/company/help
http://:8080/company aboutus

下面是我在远程服务器上针对Apache的virtualhost条目:

<VirtualHost *:8080>
        ServerAdmin xxxxxxx@xxx.xxx.xxx
        DocumentRoot "/app/content/pages"
        DirectoryIndex index.php
        ServerName company.xxx.xxxx.xxx
        ServerAlias company.xxx.xxxx.xxx
       LogLevel debug
        ErrorLog "|/app/server/apache2/bin/rotatelogs logs/company.xxx.xxxx.xxx-error_log 50M"

        <Directory "/app/content/pages">
            Options Includes FollowSymLinks
            AllowOverride All Options FileInfo
            Order allow,deny
            Allow from all

      <IfModule mod_php5.c>
            AddType application/x-httpd-php .php

            php_flag magic_quotes_gpc Off
            php_flag track_vars On
            php_flag register_globals Off
            php_value include_path .
          </IFModule>
    </Directory>

        #
        # The following lines prevent .htaccess and .htpasswd files from being
        # viewed by Web clients.
        #
        <FilesMatch "^\.ht">
            Order allow,deny
            Deny from all
            Satisfy All
        </FilesMatch>

        AddType text/html .shtml
        AddOutputFilter INCLUDES .shtml

        ServerSignature Off
</VirtualHost>

添加重写规则很有帮助,就像stormdain在评论中建议的那样,但更具体的帮助是添加重写库。这是我想出的有效方法

    <Directory "/app/content/pages/company">
        Options Includes FollowSymLinks
        AllowOverride All Options FileInfo
        Order allow,deny
        Allow from all

  <IfModule mod_php5.c>
        AddType application/x-httpd-php .php

        php_flag magic_quotes_gpc Off
        php_flag track_vars On
        php_flag register_globals Off
        php_value include_path .
  </IFModule>

   <IfModule mod_rewrite.c>
         RewriteEngine On
         # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
         #  slashes.
         # If your page resides at
         #  http://www.example.com/mypage/test1
         # then use
         # RewriteBase /mypage/test1/
        RewriteBase /company              ## earlier this had just a trailing slash
        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.

        ErrorDocument 404 /index.php
  </IfModule>             

</Directory>

    #
    # The following lines prevent .htaccess and .htpasswd files from being
    # viewed by Web clients.
    #
    <FilesMatch "^\.ht">
        Order allow,deny
        Deny from all
        Satisfy All
    </FilesMatch>

    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml

    ServerSignature Off

选项包括以下符号链接
允许覆盖所有选项文件信息
命令允许,拒绝
通融
AddType应用程序/x-httpd-php.php
php_标志魔术_引号_gpc关闭
php_标志跟踪_变量打开
php_标志寄存器_全局关闭
php_值包括_路径。
重新启动发动机
# !重要!在这里设置您的基础,不要忘记尾随和前导
#砍。
#如果您的页面位于
#  http://www.example.com/mypage/test1
#然后使用
#重写base/mypage/test1/
RewriteBase/company###########之前这只是一个尾随斜杠
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?/$1[L]
#如果我们没有安装mod_rewrite,所有404
#可以发送到index.php,一切正常。
ErrorDocument 404/index.php
#
#以下几行阻止.htaccess和.htpasswd文件被删除
#由Web客户端查看。
#
命令允许,拒绝
全盘否定
满足所有
AddType text/html.shtml
AddOutputFilter包括.shtml
服务器签名关闭

看起来您没有在重新编写
index.php
文件。
http://:8080/company/index.php/help
有效吗?@stormdain确实有效!!谢谢什么地方最好?是否应将其添加到httpd-vhosts.conf virtualhost条目中?通常,人们会在Ci应用程序的根文件夹中放置一个
.htaccess
,其中包含“重写”。看见
$route['(:num)'] = "home/index/$1";
$route['help'] = "home/help";
$route['home/(:num)'] = "home/index/$1";
$route['default_controller'] = "home";
$route['404_override'] = '';
    <Directory "/app/content/pages/company">
        Options Includes FollowSymLinks
        AllowOverride All Options FileInfo
        Order allow,deny
        Allow from all

  <IfModule mod_php5.c>
        AddType application/x-httpd-php .php

        php_flag magic_quotes_gpc Off
        php_flag track_vars On
        php_flag register_globals Off
        php_value include_path .
  </IFModule>

   <IfModule mod_rewrite.c>
         RewriteEngine On
         # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
         #  slashes.
         # If your page resides at
         #  http://www.example.com/mypage/test1
         # then use
         # RewriteBase /mypage/test1/
        RewriteBase /company              ## earlier this had just a trailing slash
        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.

        ErrorDocument 404 /index.php
  </IfModule>             

</Directory>

    #
    # The following lines prevent .htaccess and .htpasswd files from being
    # viewed by Web clients.
    #
    <FilesMatch "^\.ht">
        Order allow,deny
        Deny from all
        Satisfy All
    </FilesMatch>

    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml

    ServerSignature Off