开发者

PHP and .htaccess redirect woodoo

I'm a little stuck with with my .htaccess redirect. It was working find while I was with PHP4 but the recent move to a new host with PHP5 have changed things for which I've no clue.

I'm working on a URL shortening service. Here, for a URL like http://example.com/e72b0f, it gives me http://example.com/forward.php?e72b0f

Earlier 开发者_StackOverflow中文版with my .htaccess file, the "forward.php?" was masked (hidden). How can I bring back this behavior. Here is the .htaccess for your reference.

Options +FollowSymlinks
RewriteEngine On
RewriteBase /

RewriteCond   %{REQUEST_URI} \/([0-9a-z]{6})$ [NC]
RewriteRule   ^(.*) http://example.com/forward.php?%1 [L]

Btw, I also do not rule out the issue being in the PHP Script. The developer that did it for me is too busy to look at it.


If you rewrite to an http:// URL that the server doesn't think is in the site, mod_rewrite will do a redirect instead of just a rewrite. In order to see if this is happening, make a page that has nothing in it but

<?php echo $_SERVER['SERVER_NAME']; ?>

and see if says it's going to "nsfw.in".

Either way, you should be able to strip off the http:// nsfw.in from the beginning of the URL and just rewrite it to /forward.php?%1. You may need to add a PT flag in order for it to be interpreted as a URL and not a FS path.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜