开发者

.htaccess RewriteRule without Redirect

开发者 https://www.devze.com 2023-03-29 11:43 出处:网络
If the folder contains 2 letters (example: zz) then execute file (foofile) without redirecting to it. foofile\'s text output is to be shown on the browser.

If the folder contains 2 letters (example: zz) then execute file (foofile) without redirecting to it. foofile's text output is to be shown on the browser.

URI accessed by browser:http://www.mysite.com/zz/folder1/file1
File to be executed:    http://www.mysite.com/foofile?var1=zz&var2=/folder1/file1

This is not working since the browser shows a 404 (not found)开发者_高级运维 error:

RewriteCond %{REQUEST_URI} ^/../.*$
RewriteRule ^/(..)(/.*)$ /foofile?var1=$1&var2=$2


Try to remove preceding slashes in your RewriteRule:

RewriteRule ^(..)(/.*)$ foofile?var1=$1&var2=$2

And your RewriteCond isn't necessary.


Try this:

RewriteEngine On
RewriteRule ^/(..)(/.*)$ /foofile?var1=$1&var2=$2 

And check apache's error log

You don't need RewriteCond, as the RewriteRule already checks if the URL matches.

0

精彩评论

暂无评论...
验证码 换一张
取 消