views:

71

answers:

2

Hello,

This is my url

http://mydomain.com/Anonymous/47/comments.php

My file hosting script contains lots of rewrites, So how can I redirect this particular type of url to comments.php without conflicting with other rewrites.

My htaccess file

Options +FollowSymLinks

RewriteEngine on
##point to installation directory
##if it is the root dir,enter /
##else /otherdir
RewriteBase  /

RewriteCond %{QUERY_STRING} ^d=([a-zA-Z0-9]{8,12})$
RewriteRule ^$ download.php?id=%1&type=1 [L]

RewriteCond %{QUERY_STRING} ^d=([a-zA-Z0-9]{12})$
RewriteRule ^$ delete.php?id=%1 [L]

RewriteRule   ^file/([0-9]+)/(.*)$ download.php?id=$1&name=$2&type=2 [L]
RewriteRule   ^([a-z]{2})/file/([0-9]+)/(.*)$ download.php?setlang=$1&id=$2&name=$3&type=2 [L]
RewriteRule   ^myfolders/([0-9]+)-(.*)$ folders.php?fid=$1&name=$3&%{QUERY_STRING} [L]
RewriteRule   ^([a-z]{2})/myfolders/([0-9]+)-(.*)$ folders.php?setlang=$1&fid=$2&name=$3&%{QUERY_STRING} [L]

RewriteRule   ^topfiles/index([0-9]*)\.html$ top.php?s=$1&type=1 [L]
RewriteRule   ^([a-z]{2})/topfiles/index([0-9]*)\.html$ top.php?setlang=$1&s=$2&type=1 [L]

RewriteRule ^([a-z]{2})$ ?setlang=$1 [QSA,L]
RewriteRule ^([a-z]{2})/$ ?setlang=$1 [QSA,L]
RewriteRule ^([a-z]{2})/(.*)\.php$ $2.php?setlang=$1 [QSA,L]

RewriteRule ^content/([0-9a-zA-Z]+)\.html$ page_template.php?page=$1 [QSA,L]

<IfModule mod_security.c>
  # Turn off mod_security filtering.
  SecFilterEngine Off

  # The below probably isn't needed,
  # but better safe than sorry.
  SecFilterScanPOST Off
</IfModule>

<FilesMatch "\captcha.php$">
   Header set Cache-Control "max-age=1"
</FilesMatch>
A: 

Try this rule:

RewriteRule ^Anonymous/[0-9]+/comments\.php$ comments.php [L]
Gumbo
+1  A: 

By putting it in the last place. To process the rule no matter what, put it in the first place and add the [L] flag. Rewrite rules are processed in the order they appear. Note, if you do this in an .htaccess environment, that the rewrite rules will be started over again after a successful rewrite without real target, so you must add something like this:

RewriteRule ^comments\.php - [L]
RewriteRule ^.*/[0-9]+/comments\.php comments.php [L,QSA]
Boldewyn