doutuo7609 2011-01-12 14:34
浏览 48
已采纳

相同的文件与.php和没有.php没有任何mod_rewrite RewriteRule

I have installed a Apache (on ubuntu) with some vhosts. In the www-dirs I have a file (for example) called info.php. And I can open this file by /info.php AND /info (without the .php at the end).

There is no mod_rewrite rule in the Vhost or the dir.

And if I try a rewrite rule like:

RewriteRule ^info$ http://www.google.com/ [R=307,L]

and reopen /info (without the .php) it dosn't work.

When I change the role to

RewriteRule ^info.php$ http://www.google.com/ [R=307,L]

and reopen the /info it works.

And when I try this rule:

RewriteRule ^(.*)$ echo.php?value=$1 [L]

and open a site like /foo and print the $value I get "echo.php". When I try /foo/bar I get "echo.php/bar"

Does anyone have a tip for me?

Add: Here are some information from the phpinfo():

SCRIPT_FILENAME /var/www/test/echo.php 
QUERY_STRING    value=echo.php
REQUEST_URI     /foo
SCRIPT_NAME     /echo.php 
  • 写回答

3条回答 默认 最新

  • dtkz3186 2011-01-12 15:09
    关注

    You need a RewriteCond before your RewriteRule that matches the base case where no rewriting should occur. Otherwise your redirected request will also be rewritten.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序