My site is attacking by bots and I want to block them.
[01/Jun/2016:11:02:56 +0200] "GET /index.php?option=com_user&view=register HTTP/1.1" 301 804
i was trying
<IfModule mod_rewrite.c>
RewriteEngine On
Options +FollowSymlinks
RewriteCond %{QUERY_STRING} index.php?option=com [NC]
RewriteRule ^(.*)$ - [F,L]
</IfModule>
but its not working, where is the problem?
Remove the uri from RewriteCond's pattern
<IfModule mod_rewrite.c>
RewriteEngine On
Options +FollowSymlinks
RewriteCond %{QUERY_STRING} ^option=com [NC]
RewriteRule ^(.*)$ - [F,L]
</IfModule>
Related
I have some domain e.g domain.com
In main folder I have a phpBB forum.
I have my Somfony 3.4 app in subfolder named e.g. symfonyfolder.
I have problem with my .htaccess file.
In main folder I have normal phpBB .htaccess and I added:
RewriteRule symfonyfolder/(.*) symfonyfolder/web/$1 [L]
In symfonyfolder I do not have .htaccess file. In symfonyfolder/web I have such .htaccess file:
DirectoryIndex app.php
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^ %{ENV:BASE}/app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /app.php/
</IfModule>
</IfModule>
But then I get uri like that:
domain.com/symfonyfolder/web//web//web//web//web//web//web//web//web//web//web//web//web//web//web//web//web//web//web//
What have I done wrong?
//Ubuntu 16.04, Apache 2.4
How can I rewrite the URL so instead of looking like this:
website.com/index.php/acars
it looks like this:
website.com/index.php?p=acars
and maybe like this:
website.com/acars
here is an example i use in a symfony2 project (i think it's the default symfony htaccess):
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
RedirectMatch 302 ^/$ /index.php/
</IfModule>
</IfModule>
so every request like website.com/acars will be handled like website.com/index.php/acars
My blog is currently located at:
example.com/blog
with posts being something like:
example.com/blog/my-post
I want to edit my htaccess file so anyone that accesses
example.com/blog/my-post
would end up at:
example.com/my-post
How can I do this with an htaccess file?
UPDATE
Right now I have:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# www.
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
</IfModule>
That will forward any non-www traffic to www. However, I need to modify this to support /blog as well. I don't think my syntax is right:
RewriteCond %{HTTP_HOST} ^example\.com/blog$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
?
You cannot match /blog using HOST_NAME variable.
Have your htaccess like this:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# www.
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301,NE]
RewriteRule ^blog/(.*)$ /$1 [L,NC,R=301]
</IfModule>
This assumes there is no .htaccess in /blog/ directory. However if it is there for some reason then use this rule as first rule in /blog/.htaccess:
RewriteEngine On
RewriteRule ^(.*)$ /$1 [L,R=301]
I have php website and I have created .htaccess file. I have two rules. One for force www and other for permalink.
I want to change following Url
http://www.yatha.tv/play.php?vid=1437&id=1
to
http://www.yatha.tv/1437/1.html
But this rule does not change
RewriteRule ^([^/]*)/([^/]*)\.html$ /play.php?vid=$1&id=$2 [L]
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^yatha\.tv$
RewriteRule ^(.*)$ http://www.yatha.tv/$1 [R=301,L]
RewriteRule ^([^/]*)/([^/]*)\.html$ /play.php?vid=$1&id=$2 [L]
</IfModule>
I want to simply point the www.mysite.com/corporate to www.mysite.com/services/corporate
here is my .htaccess:
#DirectoryIndex index.php index.html
#Options +FollowSymLinks
#Options -Indexes
#ErrorDocument 403 default
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^corporate$ services/corporate
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*) index.php
RewriteCond %{HTTP:Authorization} !^$
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>
#php_value register_globals 0
Use mod_rewrite. Place something like this in .htaccess in the root directory:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)/corporate/(.*)$ $1/services/corporate/$2 [R,L]
See http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html for more info.
Difficult to understand some parts of your .htaccess code but you can add one more line before </IfModule> there:
RewriteRule ^corporate/?$ services/corporate [NC,L,R=301]