【问题标题】:htaccess file not working on server and redirecting not properly while working on localhosthtaccess 文件在服务器上不起作用并且在本地主机上工作时重定向不正确
【发布时间】:2012-06-13 05:29:17
【问题描述】:

我正在我的服务器上设置一些东西,

http://adamcyber.net/talentmasterdemo/

如果我复制数据库和应用程序并将其运行到本地主机,则将配置更改为本地主机设置(如路径和子目录)一切正常。但是当我将它上传到服务器 adamcyber.net 时。登录页面工作正常,但是当我使用凭据登录时。它进入重定向的无限循环。所以Firefox显示错误。到目前为止,我发现这是 htaccess 问题,但我不确定 y htaccess 是否在 localhost 上运行而不在服务器上运行,配置为正确运行 htaccess,因此在运行 htaccess 时没有问题作为其他站点服务器正在正确运行 htaccess。下面是htaccess文件代码。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule    (.*) index.php/$1 [L]

我被困在这里了。任何帮助将不胜感激。

【问题讨论】:

    标签: php apache .htaccess


    【解决方案1】:

    试试这个

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    

    【讨论】:

    • 我试过你提供的代码,它进入主站点,404页面,主站点是wordpress的博客,它重定向到的页面显示页面未找到
    • 哦,我明白了。我发布的代码适用于您的 wordpress 站点,并且应该位于您的根 httpdocs 文件夹中。对于您在adamcyber.net/talentmasterdemo 安装的内容,您需要在该文件夹中创建一个单独的 htaccess 文件。我假设那是您发布的代码所在的位置?还。我做了一个快速的用户/密码组合,看看是否有任何服务器错误,我注意到它发回了一些数据库错误。也许您的问题出在其他地方?
    • 另外,请确保您的 htaccess 文件具有正确的权限。如果您手动上传它并且没有更改权限......它甚至可能无法使用,这可以解释为什么它在本地工作但在服务器上不起作用
    • 好的,我发现了一个问题,我的页面在验证登录凭据后重定向到 adamcyber.net/talentmasterdemo/CompanyDashboard ,这不起作用。但如果我这样说的话,adamcyber.net/talentmasterdemo/index.php/CompanyDashboard。有用 。您能否在 htaccess 中针对 index.php 问题提供解决方案
    • htaccess 表现良好,现在只是问题在于 url 中的 index.php。如果我将 index.php 放在像 adamcyber.net/talentmasterdemo/index.php/CompanyDashboard 这样的 URL 中,它就完美了。但应用程序默认重定向到 /CompanyDashboard 没有 index.php 。我们可以在 htaccess 中做些什么来重写 url
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-12
    • 2016-02-21
    • 1970-01-01
    相关资源
    最近更新 更多