You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "webmaster@invader-universal.com" <we...@invader-universal.com> on 2006/03/28 09:20:31 UTC

[users@httpd] This rewrite rule don't work - in htaccess (mod_rewrite)

Hello,

In my forum, I have a .htaccess file.

I want to add a variable in this case :
"showtopic" OR ("showtopic" AND "st") variables are present, I add this 
variable : "rfurl=original in the" URL.

Exemple :
http://www.my-domain.com/index.php?showtopic=22954
-------> (redirect to)
http://www.my-domain.com/index.php?showtopic=22954&rfurl=original

http://www.my-domain.com/index.php?showtopic=22954&st=90
-------> (redirect to)
http://www.my-domain.com/index.php?showtopic=22954&st=90&rfurl=original



But if there is also others variables, I don't add the new variable.

Exemple :
http://www.my-domain.com/index.php?showtopic=22954&view=getlastpost
http://www.my-domain.com/index.php?showtopic=22954&pid=457390&st=300&
http://www.my-domain.com/index.php?showtopic=22954&view=getnewpost
http://www.my-domain.com/index.php?showtopic=22954&hl=blouclage
I do nothing ! (don't redirect)


I have this rule in my .htaccess file (in my forum directory)

RewriteCond %{QUERY_STRING} showtopic
RewriteCond %{QUERY_STRING} !rfurl
RewriteCond %{QUERY_STRING} !view
RewriteCond %{QUERY_STRING} !gopid
RewriteCond %{QUERY_STRING} !showforum
RewriteCond %{QUERY_STRING} !pid
RewriteCond %{QUERY_STRING} !hl
RewriteRule index\.php index.php?rfurl=original[QSA,L,R]


But when I use this rule for exemple :
http://www.my-domain.com/index.php?showtopic=showtopic=61095

It don't redirect to :
http://www.my-domain.com/index.php?showtopic=showtopic=61095&rfurl=original

Because it says : "initial URL equal rewritten URL"

Look my log file :

559575:MY-IP - - [27/Mar/2006:02:31:43 --0600] 
[www.my-domain.com/sid#a067028][rid#a296fc8/initial] (3) [per-dir 
/home/my-domain/public_html/forum/] applying pattern 'index\.php' to uri 
'index.php'
559576:MY-IP - - [27/Mar/2006:02:31:43 --0600] 
[www.my-domain.com/sid#a067028][rid#a296fc8/initial] (4) RewriteCond: 
input='' pattern='!lofiversion' => matched
559577:MY-IP - - [27/Mar/2006:02:31:43 --0600] 
[www.my-domain.com/sid#a067028][rid#a296fc8/initial] (4) RewriteCond: 
input='/forum/index.php' pattern='!lofiversion' => matched
559578:MY-IP - - [27/Mar/2006:02:31:43 --0600] 
[www.my-domain.com/sid#a067028][rid#a296fc8/initial] (4) RewriteCond: 
input='showtopic=61095' pattern='showtopic' => matched
559579:MY-IP - - [27/Mar/2006:02:31:43 --0600] 
[www.my-domain.com/sid#a067028][rid#a296fc8/initial] (4) RewriteCond: 
input='showtopic=61095' pattern='!rfurl' => matched
559580:MY-IP - - [27/Mar/2006:02:31:43 --0600] 
[www.my-domain.com/sid#a067028][rid#a296fc8/initial] (4) RewriteCond: 
input='showtopic=61095' pattern='!view' => matched
559581:MY-IP - - [27/Mar/2006:02:31:43 --0600] 
[www.my-domain.com/sid#a067028][rid#a296fc8/initial] (4) RewriteCond: 
input='showtopic=61095' pattern='!gopid' => matched
559582:MY-IP - - [27/Mar/2006:02:31:43 --0600] 
[www.my-domain.com/sid#a067028][rid#a296fc8/initial] (4) RewriteCond: 
input='showtopic=61095' pattern='!showforum' => matched
559583:MY-IP - - [27/Mar/2006:02:31:43 --0600] 
[www.my-domain.com/sid#a067028][rid#a296fc8/initial] (4) RewriteCond: 
input='showtopic=61095' pattern='!pid' => matched
559584:MY-IP - - [27/Mar/2006:02:31:43 --0600] 
[www.my-domain.com/sid#a067028][rid#a296fc8/initial] (4) RewriteCond: 
input='showtopic=61095' pattern='!hl' => matched
559585:MY-IP - - [27/Mar/2006:02:31:43 --0600] 
[www.my-domain.com/sid#a067028][rid#a296fc8/initial] (2) [per-dir 
/home/my-domain/public_html/forum/] rewrite index.php -> 
index.php?rfurl=original[QSA,L,R]
559586:MY-IP - - [27/Mar/2006:02:31:43 --0600] 
[www.my-domain.com/sid#a067028][rid#a296fc8/initial] (3) split 
uri=index.php?rfurl=original[QSA,L,R] -> uri=index.php, 
args=rfurl=original[QSA,L,R]
559587:MY-IP - - [27/Mar/2006:02:31:43 --0600] 
[www.my-domain.com/sid#a067028][rid#a296fc8/initial] (3) [per-dir 
/home/my-domain/public_html/forum/] add per-dir prefix: index.php -> 
/home/my-domain/public_html/forum/index.php
559588:MY-IP - - [27/Mar/2006:02:31:43 --0600] 
[www.my-domain.com/sid#a067028][rid#a296fc8/initial] (1) [per-dir 
/home/my-domain/public_html/forum/] initial URL equal rewritten URL: 
/home/my-domain/public_html/forum/index.php [IGNORING REWRITE]



Have you an idea ?

Best regards
IU

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] This rewrite rule don't work - in htaccess (mod_rewrite)

Posted by "webmaster@invader-universal.com" <we...@invader-universal.com>.
Thank you very much

Robert Ionescu a écrit :
> webmaster@invader-universal.com wrote:
>> Because it says : "initial URL equal rewritten URL"
>
> Use an URL-path instead of a filepath in the substitution. But with 
> access to the httpd.conf - why don't you use the rules in per-server 
> context (inside of your <virtualhost>, if you're using virtual hosts)?
>
> #per-dir /forum/:
> RewriteCond %{QUERY_STRING} showtopic
> RewriteCond %{QUERY_STRING} !(rfurl|view|gopid|....)
> RewriteRule ^index\.php$ /forum/index.php?rfurl=original [QSA,L,R]
>
> #per-server:
> RewriteCond %{QUERY_STRING} showtopic
> RewriteCond %{QUERY_STRING} !(rfurl|view|gopid|....)
> RewriteRule ^/forum/index\.php$ /forum/index.php?rfurl=original [QSA,L,R]
>


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] This rewrite rule don't work - in htaccess (mod_rewrite)

Posted by Robert Ionescu <ro...@googlemail.com>.
webmaster@invader-universal.com wrote:
> Because it says : "initial URL equal rewritten URL"

Use an URL-path instead of a filepath in the substitution. But with 
access to the httpd.conf - why don't you use the rules in per-server 
context (inside of your <virtualhost>, if you're using virtual hosts)?

#per-dir /forum/:
RewriteCond %{QUERY_STRING} showtopic
RewriteCond %{QUERY_STRING} !(rfurl|view|gopid|....)
RewriteRule ^index\.php$ /forum/index.php?rfurl=original [QSA,L,R]

#per-server:
RewriteCond %{QUERY_STRING} showtopic
RewriteCond %{QUERY_STRING} !(rfurl|view|gopid|....)
RewriteRule ^/forum/index\.php$ /forum/index.php?rfurl=original [QSA,L,R]

-- 
Robert

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org