繁体   English   中英

错误404:我网站上的链接不起作用,仅索引(使用Codeigniter和.htaccess)

[英]Error 404: The links on my website don't work, only index (using Codeigniter & .htaccess)

我在Apache服务器上托管我的网站http://tstspanama.com/ 它是使用PHP框架Codeigniter创建的。 我只能看到主页,但没有其他内容,链接不起作用。

如果我想访问http://tstspanama.com/servicioshttp://tstspanama.com/servicios得到:

未找到

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

有谁知道如何解决这个问题? 我附上所有重要的代码。

在应用程序配置上(/var/www/tsts/application/config/config.php)

$config['base_url']     = isset($_SERVER['REQUEST_URI']) && $_SERVER['HTTP_HOST'] != 'localhost' ? 'http://'.$_SERVER['HTTP_HOST'].'/' : 'http://www.tstspanama.com/';

$config['index_page'] = '';

$config['uri_protocol'] = 'AUTO';

在我的.htaccess上

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /tsts/
    RewriteCond $1 !^(index\.php|assets|images|css|js|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php/$1 [QSA,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>

<ifModule mod_php5.c>
    php_value default_charset utf-8
</ifModule>

php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on

在/etc/apache2/sites-available/www.tstspanama.com上

<VirtualHost *:80>
    ServerName www.tstspanama.com
    ServerAlias tstspanama.com

    DocumentRoot /var/www/tsts
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>

    <Directory /var/www/tsts>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log
    # Possible values include: debug, info, notice, warn, error,
    # crit, alert, emerg.
    LogLevel error
    CustomLog /var/log/apache2/access.log combined
    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
</VirtualHost>

如果添加RewriteBase ,则请考虑使用url,因此请将其删除或使用/

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteCond $1 !^(index\.php|assets|images|css|js|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php/$1 [QSA,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>

<ifModule mod_php5.c>
    php_value default_charset utf-8
</ifModule>

php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM