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 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥15 python爬取bilibili校园招聘网站
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置