Difference between Apache rules to block libwww-perl [closed] - security

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I want to know the difference between these rules and which is most effective to block libwww-perl with the file .htaccess
SetEnvIfNoCase User-Agent "libwww-perl" bad_bot
Order Deny,Allow
Deny from env=bad_bot
or
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
Thank you!

Functionally, I think they are much the same, with some minor pros and cons. However the former is probably more portable, since you won't have worry about mod_rewrite being installed on the server should you move the site at some point in the future.
Naturally, if you have other mod_rewrite rules this won't make much difference to you.
You also have a wildcard set up in the mod_rewrite rule, that isn't present in SetEnvIfNoCase. I understand this is possible to do this there also, and it might be wise to do so, since you can then catch different libwww versions.
I'm sure you know libwww-perl can send an arbitrary user agent string, so neither will stop the determined.

Related

How to use url rewrite with parameters [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
How to use url rewrite with parameters
example.com/news.php?id=1 to example.com/news/1
And the value of number will change dynamically.
RewriteEngine On
RewriteRule ^news/([0-9]*)$ /news.php?id=$1 [L]
Yes, there are many similar questions. But here is how to do it.
RewriteEngine On
RewriteRule ^news/([0-9]+)/?$ news.php?id=$1 [NC,L]
You should have mod_rewrite enabled in your server.

htaccess mod_rewrite q, lets users see non existing page [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
So I have the following in my .htaccess for my mod_rewrite.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)$ /?a=$1 [L]
RewriteRule ^product/([^/]*)$ /product.php?p=$1 [L]
It let's me have /help instead of .index.php?a=help but the problem is that if someone visits /blahblah is doesn't give an error, it just displays a blank index page with nothing on it except the logo, sidebar and blank content space.
Any ideas how to stop this? I was gonna use php if() but that seems to cumbersome because I have to do it every time I add a page. Any way with .htaccess?
You have to use php here. Your index.php reads the $_GET['a'] variable and determines what content to render. But mod_rewrite has zero knowledge of what is or what isn't renderable content by the index.php file.
The implementation will depend on how your index.php is written. If you can't find the page denoted by the "a" parameter, then it's up to index.php to return a 404 result. There's no way to do this in htaccess.

301 complex redirection via .htaccess [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Hi Guys i'm currently in the middle of a migration, and need the clients traffic to be sent as a fail save the new url's.
The old domain would have something like olddomain.com/abcd/1234 and i need to redirect that to newdomain.com/?paramenter1=1234&parameter2=ABCD.
This is probably something easy to do and i'm guessing this can be done via a .htaccess request so we can make sure there's no left over traffic. I'm not a developer but i'm a techie and need to advise the client's tech on placing this one since this is actually my idea to help them out.
Any help would be much appreciated!
Thanks in advance!
The following .htaccess rule will redirect http://olddomain.com/abcd/1234 to http://newdomain.com/?paramenter1=abcd&parameter2=1234.
Notice that the two captured groups (defined by parantheses) from the regular expression are numbered from 1 and up. So the first captured group will be accessible in the redirect url as $1 while the second group will be accessible as $2. Please adjust accordingly to your requirements.
RewriteRule ^(.+)/(.+)$ http://newdomain.com/?parameter1=$1&parameter2=$2 [R=301,L]

.htaccess to allow #fontface [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I am using the master .htaccess from http://docs.joomla.org
Its working well but its also locking out all my woff|eot|svg|ttf
How can I add these to the allowed filetypes?
My fonts reside in /templates/mytemplate/css/type/ folder
I believe this is the line in question:
## Allow limited access for certain Joomla! system directories with client-accessible content
RewriteRule ^(components|modules|plugins|templates)/([^/]+/)*([^/.]+\.)+(jp(e?g|2)?|png|gif|bmp|css|js|swf|html?|mp(eg?|[34])|avi|wav|og[gv]|xlsx?|docx?|pptx?|zip|rar|pdf|xps|txt|7z|svg|od[tsp]|flv|mov)$ - [L]
Basically, in certain folders - including the templates/ folder, only certain file types are being allowed and your files aren't in the list. Adding them in the final bracketed clause pipe separated should do the job. Something like...
RewriteRule ^(components|modules|plugins|templates)/([^/]+/)*([^/.]+\.)+(jp(e?g|2)?|png|gif|bmp|css|js|swf|html?|mp(eg?|[34])|avi|wav|og[gv]|xlsx?|docx?|pptx?|zip|rar|pdf|xps|txt|7z|svg|od[tsp]|flv|mov|woff|eot|svg|ttf)$ - [L]

htaccess redirect url parameter as segment [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Is it possible to redirect url parameters as segments in .htaccess file?
i.e.
test/index.php?parameter=MYVALUE
to
test/MYVALUE/
Yes. Try this:
RewriteCond %{QUERY_STRING} parameter=(.*)
RewriteRule test/index\.php test/%1
According to "What is matched?" in the mod_rewrite docs, the query string (part after the ?) is separated out into the QUERY_STRING variable, which then has to be tested separately from the main part of the URL. In RewriteCond, the parameter value is captured by the regular expression within the parentheses (.*), and is then available as %1 in the RewriteRule.

Resources