Home > Net >  .htaccess rewriteCond that ignores your own domain
.htaccess rewriteCond that ignores your own domain

Time:02-24

If I have a rule in .htaccess like this:

RewriteCond %{QUERY_STRING} ^URL\=(. ?)(-[0-9] )?$
RewriteRule ^(.*)$ /index.php? [R=404,L]

how would I change it so that ignores anything after ?URL= from the site's own domain?

For example, my-domain.com?URL=http://porn.site gets redirected, but my-domain.com?URL=https://my-domain.com/some-page is ignored.

CodePudding user response:

You can use:

RewriteCond %{QUERY_STRING} !^URL\=https?://my-domain.com [NC]
RewriteCond %{QUERY_STRING} ^URL\=(. ?)(-[0-9] )?$
RewriteRule ^(.*)$ /index.php? [R=404,L]
  • Related