ModRewrite和php文件

时间:2016-05-31 06:09:08

标签: php .htaccess mod-rewrite

在服务器上就是这个规则:

RewriteEngine On
RewriteBase /www_new

因为其他项目很少。我现在必须将所有内容指向该文件夹。我有swf,woff,svg和ttf文件的问题,但我在这里添加它们并且它正常工作

RewriteRule !\.(swf|woff|svg|ttf|pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$ index.php [L]

但我的问题是我不能将它用于文件uploadify.php

我怎能指出它?

也许有一些重写规则?如果地址是/something/uploadify.php,那么请指向/www_new/something/uploadify.php

此外,最好是该规则只适用于主服务器,而不是localhost。

感谢您提出任何建议

1 个答案:

答案 0 :(得分:1)

您可以在现有规则之前使用以下规则:

RewriteEngine on
# this checks to see that the requested uri value is not starting with the "target folder" and prevents rewrite looping 
RewriteCond %{REQUEST_URI} !^/www_new
# rewrite /anychar/uploadify.php to /www_new/anychar/uploadify.php 
RewriteRule ^(.*uploadify\.php)$ /www_new/$1 [L]
相关问题