I am using polish CMS called Batflat, which .htaccess does not allow access to txt files. I only need to get access to robots.txt other txt files may no be accessible.
.htaccess content:
# Prevent directory listings
Options -Indexes
# Prevent visitors from viewing files directly
<FilesMatch "\.(sdb|md|html|txt)$">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
</FilesMatch>
# URL rewrites
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(inc/|themes/|tmp/).*\.(php|html)$ - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
</IfModule>
I am not familiar with .htaccess - could you help me solve my problem?
Thank you
SK
I have received answer 5 line should be:
<FilesMatch "(\.(sdb|md|html|txt)|(?<!robots.txt))$">
Maybe it will solve someone problem.
Greets
SK
Related
Please I have an issue with my website, suddenly I can't loginto the dashbord, I've de msg 403 "You don't have permission to access this resource."... Impossible de solve for me, I've tried to delete the .htaccess file, disable all plugins and grant permission to all directory and sub-directory but nothing, i think that it's a hack. I also noticed that when I delete the .htaccess file he automaticaly reappear again and into this file I see a suspect line :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
<FilesMatch ".*\.(py|exe|phtml|php|PHP|Php|PHp|pHp|pHP|phP|PhP|php5|suspected)$">
Order Allow,Deny
Deny from all
</FilesMatch>
<FilesMatch "^(old-index.php|wp-admin.php|1index.php|2index.php|3index.php|wikindex.php|index.php|wp-load.php|admin.php|wp-login.php)$">
Order Allow,Deny
Allow from all
</FilesMatch>
I see several file like 1index.php, 2index.php, wikindex.php, ... and I never see them.
Please try guide me to find the solution...
I am trying to install a app I bought off of ThemeForest and I cannot get the administration center to work.
The admin folder tree looks like this
^Admin
->Lib (Folder)
->Assets (Folder)
->Src (Folder)
->More Stuff etc (Folder)
index.php (File)
The index.php file calls other files in the folders, however the browser only calls for http://url/admin/file
This makes me believe this is a url rewrite issue, however I cannot figure out how to convert this .htaccess file to Nginx
Options -Indexes
<ifModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
# Index handles everything
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*)$ index.php?path=$1 [NC,L,QSA]
</IfModule>
<FilesMatch "_connect.php|_somesome.php">
Order Allow,Deny
Deny from all
</FilesMatch>
<Files .htaccess>
Order Allow,Deny
Deny from all
</Files>
My front url is-
http://localhost/myProject/
admin url is -
http://localhost/myProject/admin
It works in windows but not works on Ubuntu.
It gives error "Not found".
What works in ubuntu -
The front page is working - http://localhost/myProject/
The admin login page is working if I add index.php in url like this -
http://localhost/myProject/index.php/admin
Not other pages are working
My .htaccess file contents-
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|themes)
RewriteRule ^(.*)$ /myProject/index.php/$1 [L]
My Apache's mod-rewrite module is on.
I was also following the similar issue in Centos, and I followed the below tutorial :
How to permit changes in the .htaccess file:
open httpd using ------------------> vi /etc/httpd/conf/httpd.conf
Once inside that file, find the following section, and change the line that says AllowOverride from None to All. The section should now look like this:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
After you save and exit that file, restart apache. .htacess files will now be available for all of your sites.
service httpd restart
Content of .htaccess file:
<IfModule mod_rewrite.c>
Options +FollowSymLinks -Indexes
RewriteEngine on
# NOTICE: If you get a 404 play with combinations of the following commented out lines
#AllowOverride All
#RewriteBase /
# Restrict your site to only one domain
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|fonts|js|images|robots\.txt|css)
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
</IfModule>
#prevent access to htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
#disable directory browsing
Options All -Indexes
IndexIgnore *
I'm trying to create an app with laravel 4 but i'm facing a url issue. i have wamp installed on my machine. i set up a new virtual host in my httpd-vhost.conf with this code
<VirtualHost mobile.dev>
DocumentRoot "C:\wamp\www\mobile.dev\public"
ServerName mobile.dev
<Directory "C:\wamp\www\mobile.dev">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
Allow from 127.0.0.1
Deny from all
Require all granted
</Directory>
mobile.dev is a folder and also the domain name in my localhost.
here is my Route.php file
Route::get('/','HomeController#showWelcome');
Route::post('login','LoginController#userLogin');
Route::get('login','LoginController#getUsers');
when i ask for mobile.dev/login it gives me the requested url was not found.
can you help me please solve this issue. but when i ask for mobile.dev/ its working.
Here is my .htaccess file :
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Here is more details. when i remove my htaccess content everything works fine with the default url http://mobile.dev/index.php/login
So the problem is in my htaccess and the rewriting in my virtual host
It might be not Laravel problem, but seems your wamp server haven't enabled mod_rewrite in httpd.conf file yet. Locate the line -
#LoadModule rewrite_module modules/mod_rewrite.so
and remove the comment symbol '#'. Then save the file and restart Apache.
Solution:
1- when you have wamp installed in your machine please go to C:\wamp\bin\apache\Apache*.*.*\conf\httpd.conf and make sure that rewrite_mod is enabled by deleting the hash tag. (instead of using the interface provided by wamp)
2-there are two ways to enable rewriting for laravel in .htaccess file :
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
or using this :
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
3- if you're setting a virtual host be sure to add this option in the <virtualhost> tag
<Directory "C:\wamp\www\mobile.dev\public">
Options FollowSymLinks Indexes Multiviews
AllowOverride All
</Directory>
Thanks a lot for your time.
Have you tried
Route::post('login','LoginController#userLogin');
without the () after userLogin?
Your <Directory "C:\wamp\www\mobile.dev"> in config should be <Directory "C:\wamp\www\mobile.dev\public"> to specify the public directory to the root of the htaccess rewrite rules.
I originally thought you were missing the </IfModule> at the end of your .htaccess file but when I posted my .htaccess file it hid the </IfModule> as well so that is a stack overflow issue. Otherwise your htaccess is correct.
I want to run a php script on my site from a newly created subdirectory.
However I am finding that my existing wordpress blog (running from doc root) is intercepting my url to the script in subdir and giving me a 404.
How can I get wordpress to ignore the subdirectory?
EDIT: based on comment, here is my .htaccess file contents:
# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName example.com
AuthUserFile /home/xxx/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/xxx/public_html/_vti_pvt/service.grp
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Based on pekka's comment, I fixed my own problem with following (where folder1 is the subdirectories i want wordpress to ignore):
=========[ start of .htaccess snippet]==========
<IfModule mod_rewrite.c>
RewriteEngine on
#
# stuff to let through (ignore)
RewriteCond %{REQUEST_URI} "/folder1/"
# other existing rules go here:
RewriteRule (.*) $1 [L]
#
====================[ end ]=====================
Pekka, if you put your comment as an answer, i will credit you.
Thanks
Another solution:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(stats|failed_auth\.html).*$ [NC]
RewriteRule . - [L]
</IfModule>
This one worked perfectly for me.
Source: http://wiki.dreamhost.com/Making_stats_accessible_with_htaccess