Mod rewrite Can';我不能让ModRewrite在Ubuntu下工作
我不知道ModRewrite有什么不对。rewrite.load和proxy.load已使用a2enmod加载,并且都显示在“模块启用”下。我试着设置我能想到的最基本的ModRewrite场景,但它根本没有重定向,我仍然收到相同的404错误消息,即使它们没有被启用 下面是我的目录Mod rewrite Can';我不能让ModRewrite在Ubuntu下工作,mod-rewrite,ubuntu,apache2,Mod Rewrite,Ubuntu,Apache2,我不知道ModRewrite有什么不对。rewrite.load和proxy.load已使用a2enmod加载,并且都显示在“模块启用”下。我试着设置我能想到的最基本的ModRewrite场景,但它根本没有重定向,我仍然收到相同的404错误消息,即使它们没有被启用 下面是我的目录 /var/www /test showimage.php //showimage.jpg should redirect here test.html //a page with
/var/www
/test
showimage.php //showimage.jpg should redirect here
test.html //a page with a <img> tag that points to showimage.jpg
.htaccess //I've tried putting this in /var/www but it doesn't work either
下面是test.html
下面是showimage.php
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /var/www/test
RewriteRule ^showimage.jpg?(.*) http://localhost/test/showimage.php?$1
RewriteRule ^test.jpg http://localhost/test/showimage.php
最后,这里是我目前在apache上唯一启用的站点:
<html>
<body>
<img alt="didn't work" src="showimage.jpg?thing=thing1" />
</body>
</html>
服务器管理员webmaster@localhost
DocumentRoot/var/www
选项如下符号链接
允许超越所有
选项索引跟随符号链接多视图
不允许超限
命令允许,拒绝
通融
ScriptAlias/cgi-bin//usr/lib/cgi-bin/
不允许超限
选项+执行CGI-多视图+符号链接所有者匹配
命令允许,拒绝
通融
ErrorLog/var/log/apache2/error.log
#可能的值包括:调试、信息、通知、警告、错误、临界值、,
#警惕,埃默格。
日志级别警告
CustomLog/var/log/apache2/access.log组合
别名/doc/“/usr/share/doc/”
选项索引多视图跟随符号链接
不允许超限
命令拒绝,允许
全盘否定
允许从127.0.0.0/255.0.0.0::1/128开始
有人知道为什么modrewrite的设置不起作用吗?您在所有相关目录中都有
允许无覆盖。我相信您需要相关目录的AllowOverride FileInfo选项
(至少),在本例中,该目录似乎是/var/www
编辑:
如果不清楚,我指的是您的虚拟主机配置,而不是.htaccess中的任何内容。您在所有相关目录中都有AllowOverride None
。我相信您需要相关目录的AllowOverride FileInfo选项
(至少),在本例中,该目录似乎是/var/www
编辑:
如果不清楚,我指的是您的虚拟主机配置,而不是.htaccess中的任何内容。在AllowOverride All
中更改AllowOverride None
并重新启动服务器。在AllowOverride All
中更改AllowOverride None
并重新启动服务器。是的!非常感谢,伙计。此外,我必须在第一次重写时将正则表达式更改为:RewriteRule^showimage.jpg(.*)。非常感谢。是的!非常感谢,伙计。此外,我必须在第一次重写时将正则表达式更改为:RewriteRule^showimage.jpg(.*)。非常感谢。
<?php
header('Content-Type: image/jpeg');
$im = imagecreatetruecolor(400, 30);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
if(isset($_GET["thing"])) {
$text = $_GET["thing"];
}
else {
$text = "none set by GET params";
}
$font = "some.ttf";
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
imagejpeg($im);
imagedestroy($im);
?>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
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 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>