mod_rewrite的工作在本地主机,但不能在服务器 [英] mod_rewrite works on localhost but not on server

查看:118
本文介绍了mod_rewrite的工作在本地主机,但不能在服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说,我重写规则不,当我把它上传到我的服务器(Ubuntu的LTS)的工作。该的.htaccess文件是在玩,但什么都不做。

mod_rewrite的加载,我已经验证了几种方法。我试图在.htaccess文件中写入垃圾文本,并得到了500内部错误,因此文件似乎是在循环。在虚拟主机配置有​​有的allowOverride全部。

.htaccess文件包含了一系列的重写规则,如:

 重写规则^网店$的index.php?网页=网店[QSA]

重写规则^网店/([0-9] +)$ index.php页面=网上商店和放大器; CATID = $ 1 [QSA]
 

在服务器我要virtualhosts,一个公用服务器和一台测试服务器。公共服务器工作正常,所有的规则集类似于上面和作品。这是虚拟主机为不想玩测试。一台服务器,一个IP,两个FQDN。

想法?

编辑 - 这里的虚拟主机配置:

 <虚拟主机*:80>
        的ServerAdmin beta@example.com
        服务器名beta.example.com

        的DocumentRoot的/ var / WWW /测试/ WWW根
        <目录/>
                有FollowSymLinks
                设置AllowOverride所有
        < /目录>
        <目录/ var / WWW /测试/ WWW根>
                AddDefaultCharset UTF-8
                有FollowSymLinks多视图
                设置AllowOverride所有
                订购允许,拒绝
                从允许(两个IP地址略)
        < /目录>

        <目录/ var / WWW /温度>
                所有允许
        < /目录>

        的ScriptAlias​​ / cgi-bin目录/ / usr / lib目录/ cgi-bin目录/
        <目录/ usr / lib目录/ cgi-bin目录>
                设置AllowOverride无
                选项​​+ ExecCGI -MultiViews + SymLinksIfOwnerMatch
                订购允许,拒绝
                所有允许
        < /目录>

        错误日志/var/log/apache2/error.beta.log

        #可能的值包括:调试,信息,通知,警告,错误,暴击,
        #警觉,EMERG。
        日志级别警告

        的CustomLog /var/log/apache2/access.log结合

    别名/ DOC /的/ usr /共享/ DOC /
    <目录的/ usr /共享/ DOC />
        选择多视图索引了FollowSymLinks
        设置AllowOverride无
        订单拒绝,允许
        所有拒绝
        从127.0.0.0/255.0.0.0允许:: 1/128
    < /目录>

< /虚拟主机>
 

解决方案

这个问题似乎是存在具有相同名称为(的一部分)的正则表达式的文件夹。我有一个名为webshop.php文件,由于某种原因,正则表达式 ^网店$ 然后失败(服务器似乎preFER实际的文件夹/文件,而不是当地重写)。

AS the title says, my rewrite rules does not work when I upload it to my server (Ubuntu LTS). The .htaccess-file is in play, but does nothing.

mod_rewrite is loaded, I've verified that several ways. I tried writing rubbish text in the .htaccess file and got a 500 internal error, so the file seems to be in the loop. The virtualHost configuration has "allowOverride All".

The .htaccess file consists of a series of rewrite rules, such as:

RewriteRule ^webshop$ index.php?page=webshop [QSA]

RewriteRule ^webshop/([0-9]+)$ index.php?page=webshop&catID=$1 [QSA]

On the server I have to virtualhosts, one public server and one testing server. The public server works fine, all rewriterules are similar to above and works. It's the virtualhost for testing that doesn't want to play. One server, one IP, two FQDNs.

Ideas?

EDIT - Here's the VirtualHost config:

<VirtualHost *:80>
        ServerAdmin beta@example.com
        ServerName beta.example.com

        DocumentRoot /var/www/beta/www-root
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /var/www/beta/www-root>
                AddDefaultCharset utf-8
                Options FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                Allow from (Two IPs omitted)
        </Directory>

        <Directory /var/www/temp>
                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.beta.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        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>

解决方案

The problem seems to be that there is a folder with the same name as (a part of) the regex. I have a file called "webshop.php", and for some reason the regex ^webshop$ then fails (servers seems to prefer the actual folder/files rather than a local rewrite).

这篇关于mod_rewrite的工作在本地主机,但不能在服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆