1

好的,基本上

http://miniqr.com/http://www.anyurl.com/

(没有错字)

应该打电话

http://miniqr.com/api/create.php?content=http://www.anyurl.com/

为了实现这一点,我在根 .htaccess 中有这个

RewriteRule ^http:\/\/(.*)$ \/api\/create.php\?content=http:\/\/$1 [L]

RewriteRule ^https:\/\/(.*)$ \/api\/create.php\?content=https:\/\/$1 [L]

可悲的是,它曾经工作过,然后服务器被更新,现在它不起作用

有人知道为什么吗?(或知道另一种方法)帮助会很棒

我的 .htaccess 看起来像这样:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^miniqr\.com$ [NC]
RewriteRule ^(.*)$ http://miniqr.com/$1  [L,R=301]

RewriteRule ^(^$|index\.php|robots\.txt|docs|reader\/) - [L]
RewriteRule ^http:\/\/(.*)$ \/api\/create\.php\?content=http:\/\/$1  [L]
RewriteRule ^https:\/\/(.*)$ \/api\/create\.php\?content=https:\/\/$1  [L]
4

2 回答 2

1

URL 路径在RewriteRule看到之前被规范化,特别//是被替换为/. 您应该将规则应用于原始请求,而不是像这样:

RewriteCond %{REQUEST_URI} ^/(https?:.*)
RewriteRule ^ /api/create.php?content=%1 [L]

%1指的是由 完成的比赛RewriteCond
%{REQUEST_URI}是 HTTP 请求第一行中的实际查询。


或者,不那么严格并在方案之后接受单个/以及//,因为路径可能由用户代理或代理类似地标准化。

于 2011-03-01T12:35:00.397 回答
0

这不会引入重定向循环吗?:

RewriteCond %{HTTP_HOST} !^miniqr\.com$ [NC]
RewriteRule ^(.*)$ http://miniqr.com/$1  [L,R=301]

你想用它实现什么?

于 2011-03-01T12:21:33.730 回答