0

Since am new to htacess so i generated htacess file here and bellow is my code

Order allow,deny
<Files .htaccess .htpasswd .htuser .htgroups >
order allow,deny
deny from all
</Files>
<IfModule !mod_ssl.c>
Redirect permanent / https://www.domain.com/
</IfModule>
RewriteEngine  on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteRule \.(gif|jpg|png)$ - [F]  
RewriteCond %{HTTP_USER_AGENT} Wget [OR] 
RewriteCond %{HTTP_USER_AGENT} CherryPickerSE [OR] 
RewriteCond %{HTTP_USER_AGENT} CherryPickerElite [OR] 
RewriteCond %{HTTP_USER_AGENT} EmailCollector [OR] 
RewriteCond %{HTTP_USER_AGENT} EmailSiphon [OR] 
RewriteCond %{HTTP_USER_AGENT} EmailWolf [OR] 
RewriteCond %{HTTP_USER_AGENT} ExtractorPro 
RewriteRule ^.*$ deny.html [L]
ErrorDocument 400 400.php
ErrorDocument 401 401.php
ErrorDocument 403 403.php
ErrorDocument 404 404.php
ErrorDocument 500 405.php
DirectoryIndex index.php

Produces the error:

[Wed Jan 07 19:09:22.207084 2015] [core:alert] [pid 5032:tid 964] [client 200.195.156.150:43841] C:/wamp/www/.htaccess: Multiple <Files> arguments not (yet) supported.

and error mod_rewrite even configured following method
when i delete mt htacess file and run my server my index page open , all ErrorDocument page and htacess and index page are in root folder can any one help me whats wrong

Community
  • 1
  • 1
  • 4
    Look in your error log. If there's an Internal Server Error, it will be detailed there. – Michael Berkowski Jan 07 '15 at 14:09
  • First remove all code and add one by one line to debug and also use the error log to check what is the error. – Vijay Verma Jan 07 '15 at 14:11
  • @MichaelBerkowski when i run without `htacess` page laods –  Jan 07 '15 at 14:13
  • @learn I understand that. You need to look in the error log to find out why this .htaccess is failing. – Michael Berkowski Jan 07 '15 at 14:15
  • 1
    @learn the problem is, that your HTACCESS throws an Error and loading isn't possible anymore .. so take a look in the apache error.log to find and solve the error(s) – donald123 Jan 07 '15 at 14:16
  • @MichaelBerkowski since am new programming language where do i get error log –  Jan 07 '15 at 14:17
  • @learn That depends on your server environment or your host. If you have a VPS it would be in `/var/log/apach2` or `/var/log/httpd` probably. If you have shared hosting, consult their documentation. – Michael Berkowski Jan 07 '15 at 14:18
  • is there any way or how do i create `htacess` file –  Jan 07 '15 at 14:20
  • @MichaelBerkowski can you tell me how to find error log in localhost so that it will be easy to find instead server –  Jan 07 '15 at 14:21
  • Have you enabled mod_rewrite? I am suspecting that you didn't and that it does not understand the `RewriteCond` and `RewriteRule` directives. – Sumurai8 Jan 07 '15 at 14:23
  • You still haven't said what platform you're working. The error log on `localhost` could be in many possible places. – Michael Berkowski Jan 07 '15 at 14:23
  • @Sumurai8 so what are the rules i should follow when i add `htacess` file since am new i just upload (php,css,js,image file) via FTP and i didn't do anything on server –  Jan 07 '15 at 14:25
  • @MichaelBerkowski in `localhost` i get this error what do?? –  Jan 07 '15 at 14:26
  • http://stackoverflow.com/questions/3131236/how-do-you-enable-mod-rewrite - Possibly http://stackoverflow.com/questions/19713001/where-can-i-find-the-wamp-error-log if you are using WAMP. – Sumurai8 Jan 07 '15 at 14:28
  • 2
    I still don't get how people run web servers and don't have basic pricinples down to check the error log when there is an issue. You can't guess your way through development. – Panama Jack Jan 07 '15 at 14:31
  • @learn In localhost, just as on a production web server, you _check the error log_. I cannot tell you where to find that log, because you have not told us what OS you use on localhost to develop this. – Michael Berkowski Jan 07 '15 at 14:32
  • @MichaelBerkowski am using wamp server in windows 8 to run php files in local host –  Jan 07 '15 at 14:37
  • @learn Then [here is how to find the error log](http://stackoverflow.com/questions/19713001/where-can-i-find-the-wamp-error-log) – Michael Berkowski Jan 07 '15 at 14:38
  • @MichaelBerkowski last help when add `htacess` file in server what are all things i should change to activate my `htacess` file working –  Jan 07 '15 at 14:41
  • @MichaelBerkowski `::1 - - [07/Jan/2015:14:05:17 +0530] "GET /favicon.ico HTTP/1.1" 500 614 ::1 - - [07/Jan/2015:14:05:31 +0530] "GET / HTTP/1.1" 500 614 ::1 - - [07/Jan/2015:14:05:31 +0530] "GET / HTTP/1.1" 500 614` my error log –  Jan 07 '15 at 14:43
  • @learn that looks like the contents of an access log, not of an error log. – Michael Berkowski Jan 07 '15 at 14:44
  • @MichaelBerkowski am sry here `[Wed Jan 07 19:09:22.207084 2015] [core:alert] [pid 5032:tid 964] [client 200.195.156.150:43841] C:/wamp/www/.htaccess: Multiple arguments not (yet) supported.` –  Jan 07 '15 at 14:46
  • 1
    It clearly tells you `` is not supported. Which is correct, you need to have the pipe delimiter in there for multiple types. http://www.askapache.com/htaccess/using-filesmatch-and-files-in-htaccess.html – Panama Jack Jan 07 '15 at 14:53
  • @PanamaJack so whats the solution –  Jan 07 '15 at 15:00

2 Answers2

0

Try using FilesMatch instead of Files, I think this was the part generating an error.

<FilesMatch "\.(htaccess|htpasswd|htuser|htgroups)$">
Order Allow,Deny
Deny from all
</FilesMatch>

I left rest of a code unchanged.

<IfModule !mod_ssl.c>
Redirect permanent / https://www.domain.com/
</IfModule>
RewriteEngine  on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteRule \.(gif|jpg|png)$ - [F]  
RewriteCond %{HTTP_USER_AGENT} Wget [OR] 
RewriteCond %{HTTP_USER_AGENT} CherryPickerSE [OR] 
RewriteCond %{HTTP_USER_AGENT} CherryPickerElite [OR] 
RewriteCond %{HTTP_USER_AGENT} EmailCollector [OR] 
RewriteCond %{HTTP_USER_AGENT} EmailSiphon [OR] 
RewriteCond %{HTTP_USER_AGENT} EmailWolf [OR] 
RewriteCond %{HTTP_USER_AGENT} ExtractorPro 
RewriteRule ^.*$ deny.html [L]
ErrorDocument 400 400.php
ErrorDocument 401 401.php
ErrorDocument 403 403.php
ErrorDocument 404 404.php
ErrorDocument 500 405.php
DirectoryIndex index.php
Poodel
  • 1
  • 1
  • Other than the first line missing, this is identical to the code in the question. I just did a diff on the two – Chris Jan 07 '15 at 14:36
  • I guess I should have been more precise, sorry. I suggested using FilesMatch directive instead of Files - it is a preferred way when dealing with multiple files (and it seems that this part was causing an error). – Poodel Jan 07 '15 at 15:00
  • @learn Could you please post a log error generated after applying changes I suggested? Seems a bit odd that the error is exactly the same... – Poodel Jan 07 '15 at 15:54
  • @Poodel `C:/wamp/www/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration` –  Jan 07 '15 at 16:01
  • OK. The problem with files is gone, now you need to enable mod_rewrite: http://stackoverflow.com/questions/10144634/htaccess-invalid-command-rewriteengine-perhaps-misspelled-or-defined-by-a-m – Poodel Jan 07 '15 at 16:10
  • am almost done only one `C:/wamp/www/.htaccess: Multiple arguments not (yet) supported.` –  Jan 07 '15 at 16:17
  • @Poodel your above code redirect me to `www.domain.com` how to disable that –  Jan 07 '15 at 16:19
  • It is because of this fragment of your code: `Redirect permanent / https://www.domain.com/` Not sure what was the idea behind this, but if you don't want to redirect, just delete this fragment. – Poodel Jan 07 '15 at 16:22
-1

Remove all Code from .htaccess and only keep the following code.

RewriteEngine  on
ErrorDocument 400 400.php
ErrorDocument 401 401.php
ErrorDocument 403 403.php
ErrorDocument 404 404.php
ErrorDocument 500 405.php
DirectoryIndex index.php
Cms Coders
  • 41
  • 1
  • 6
  • but i need all `rewrite` rule –  Jan 07 '15 at 14:22
  • Are you use any cms? like wordpress – Cms Coders Jan 07 '15 at 14:38
  • @CmsCoders If I may suggest something, please take a look at [this help item](http://stackoverflow.com/help/how-to-answer). Some of your answers are just of dramatic quality, and after going through all of them I couldn't find any that I would consider upvoting. I would suggest going through your old answers and editing them to improve their quality. – Sumurai8 Jan 07 '15 at 16:01
  • sure i will take care next time – Cms Coders Jan 07 '15 at 19:41