i have a magento webshop which has following rule in his base .htaccess file:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
Now i have a subdirectory in the webshop root called "oscware". In this folder is also a htaccess file with following content:
AuthType Basic
AuthName "Please enter your ID and password"
AuthUserFile .htpasswd
require valid-user
if i want to connect to http://www.example.com/oscware/oscware-connector.php i will be redirected to the magento shop with error 404.
If i remove the rule
RewriteRule .* index.php [L]
it works. Ok everybody should think that the problem is in the rewrite condition. But it is NOT so. Because at the other side if i remove the rule
require valid-user
in the .htaccess file in the oscware directory it also works (with the rule
RewriteRule .* index.php [L]
)
At the end i can only edit the magento .htaccess in the webshop-root because the oscware .htaccess is automatically generated. Has anybody an idea to get this scenario working?
Thanks in advance!
Not sure why this is happening. The only thing that I can think of is maybe an internal 401 page is missing and that's somehow causing the rule in the document root to get applied. Unless there's other rules or redirects in the "oscware" or magento that is inadvertently causing this.
But try, in the htaccess file in your "oscware" folder, turn on the rewrite engine:
RewriteEngine On
Related
I have a website with two subdirectories, /1/ and /2/, appended to the end of the base url. Subsite /1/ already exists, and I'm trying to work on /2/ behind an htaccess password wall.
Going to the /1/ site works fine (and the root redirects all work as intended), but going to the /2/ site causes an infinite redirect when my htaccess password challenge is active. What am I doing wrong?
Here's the .htaccess file in the root directory:
Redirect 301 /theforum http://www.leveluplabs.com/forum
RewriteEngine On
# stuff to let through (ignore)
RewriteCond %{REQUEST_URI} "/theforum/" [OR]
RewriteCond %{REQUEST_URI} "/theforum" [OR]
RewriteCond %{REQUEST_URI} "/2/" [OR]
RewriteCond %{REQUEST_URI} "/update/" [OR]
RewriteCond %{REQUEST_URI} "/files/" [OR]
RewriteCond %{REQUEST_URI} "/download.php"
RewriteRule (.*) $1 [L]
#
RewriteRule ^(.*)$ http://www.defendersquest.com/1/$1 [R=301,L]
Here's the .htaccess in the /2/ directory:
### Generated by Dreamhost. DO NOT modify!!! ###
AuthType Basic
AuthUserFile /path/to/defendersquest.com/2/.htpasswd
AuthName "Under construction!"
require valid-user
################################################
(/path/to/ is not the real path, I redacted the actual server path).
Any ideas? The page that generates the error is:
http://www.defendersquest.com/2/
Try to add this line to the begining of the htaccess code.
ErrorDocument 401 default
That fixes the error when error handling system is confused where to send the user in a certain circumstance and goes into a loop. Sometimes it has been seen to be ending up with 404 not found.
This worked for me in a custom coded website and for a wordpress installation as well.
Look into your error.log as I suspect that either /path/to/defendersquest.com/2/.htpasswd doesn't exist OR doesn't have 644 permissions.
Request to http://www.defendersquest.com/2/ is redirecting to http://www.defendersquest.com/1/failed_auth.html which in turn doesn't exist either and causing it to go to http://www.defendersquest.com/1/missing.html and looping.
I have a directory structure like below.
public_html/
/abc/
/xyz/
/pqr/
there is a index.php in each these directories, abc,xyz,pqr.
now whenever is there any request like domain.com/abc/def/ghi should be rewritten to domain.com/abc/index.php/def/ghi
domain.com/xyz/def/ghi => domain.com/xyz/index.php/def/ghi
domain.com/pqr/def/ghi => domain.com/pqr/index.php/def/ghi
What should be the .htaccess file and where it should be placed?
I have .htaccess file in each directory(abc,xyz,pqr) like below, but it is not working. it is showing 404 page not found. Please guide me to handle all these rewrite conditions.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
But this is not working... If this is right .htaccess then please tell me if there is any other server side problem. I am setting up this on CentOs server.
You will probably need a RewriteBase /abc to deal with the subfolders.
I had problem with my directory access, I was needed to update the access for content directory(domain.com) in apache config file(httpd.conf)
I need to be able to access everything under /admin_dir without the Kohana framework interfering, since the admin_dir doesn't use the framework at all.
First off, here's my .htaccess file:
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
#Allow the admin page to be accessed
RewriteRule ^/?admin_dir(.*) admin_dir$1 [L]
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
This is the .htaccess file that comes with Kohana, minus the addition of the admin_dir rule. However, no matter what I do I can't access the admin_dir. I get a Kohana exception saying that it couldn't find a route to match if I try to access /admin_dir/index.php, or that the URL couldn't be found if I try to access /admin_dir.
The ONLY way I seem to be able to access the admin_dir is by commenting out the very last line of .htaccess. The admin_dir isn't part of the Kohana framework, so I just want to bypass it all together. I've found similar posts on SO about this, but nothing that works for my situation.
Edit:
I do have an .htaccess file in the admin_dir/ for password protection. The contents are below:
AuthType Basic
AuthName "Admin Page"
AuthUserFile "/home/mysite/.htpasswds/public_html/beta/admin_dir/passwd"
require valid-user
Thanks in advance for your help, this has been a thorn in my side for way too long!
Brian
So apparently having the .htaccess in my admin_dir directory is what was causing my problem. I don't know why or how, but after making a small change to the root .htaccess file and removing the password protection, it's all working now... with the exception of no password protection. :( I guess for that I'll just need to write a dumb little authentication thingy for it.
Here's the modification we made to the root .htaccess file:
...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/admin_dir.* [OR]
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
Thank you all for your help!
Brian
Does commenting
RewriteRule ^/?admin_dir(.*) admin_dir$1 [L]
solve your problem when you try to access http://domain.com/admin_dir/index.php ?
The rule below will tell Apache to not to do any URL rewriting for URLs that start with admin_dir
RewriteRule ^admin_dir.* - [L]
If it still does not work (it does work fine here on my test box), try removing leading ^ -- it is less accurate (as it will also be triggered for some_admin_dir) but as long as admin_dir is a unique across whole website (no other URLs have that text) then it should be fine.
UPDATE:
You may try putting this into your .htaccess from /admin_dir -- worth trying it:
RewriteEngine On
RewriteBase /admin_dir/
# stop rewriting if file/folder exist
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
I have the following htaccess which redirects front controller commands to a given file....
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)$ /index.php?a=$1 [L]
Which sits in the root of the domain and works well, however i have a password protected directory at /admin/help/ which contains the following htaccess...
AuthType Basic
AuthName "Your CMS"
AuthUserFile "/path/to/.htpasswd"
require valid-user
The problem is that i'm unable to pull up /admin/help/ in the browser, it simply rewrites to the index.php even though /admin/help/ is a real folder on the server. If i remove the .htaccess from /admin/help/ the folder displays as expected in the browser so i presume i'm missing something from this 2nd .htaccess file however i can't figure out what it is, so any suggestions would be much appreciated?
Thanks
I'm using Simple Mailing List (http://www.notonebit.com/projects/mailing-list). It's good mailing list, but no admin area. So you have to use .htaccess/.htpasswd to protect the /mail/admin folder.
However, my site has WordPress installed in the website's root folder. WordPress creates .htaccess for custom permalinks. And for some reason, this interferes with the .htaccess of my /mail/admin/.
When I delete the WordPress .htaccess file, my password protection works properly on /mail/admin. However, when the WordPress .htaccess is present and I load /mail/admin in browser, I'm never asked for a password and I see a WordPress 404 page that says "page not found..."
Here are my files... WordPress .htaccess (located in root folder):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Mailing List .htaccess (located in /mail/admin):
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /home/myUsername/public_html/mySndSite/mail/admin/.htpasswd
require valid-user
Any idea as to what is causing the conflict, and how I can resolve it? Been working at it for hours. Your help is much appreciated.
Thank You
EDIT: found a solution!
Found a solution on a Joomla blog. I don't know how, but this works... LOL :)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|#.*|\?.*|/[^.]*)$ [NC]
RewriteRule ^(.*) /index.php [L]
</IfModule>
You could try explicitly setting a conditional that the request URI not match the url for the mail script. That should prevent the rewrite from kicking in when you view the mail admin page.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !mail
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I think there must be something else going on here that we can't see. That Wordpress .htaccess code already prevents rewriting URLs when what you are trying to access is a file or a directory that exists on the server, which should be true in this case.
Are there any other .htaccess files involved anywhere, or any plugins installed in Wordpress that involve rewrites? Also, does /mail/admin/ work when you remove your .htaccess file that requires a password?
You could try, say, creating blank text files inside the /mail/admin/ directory and in a completely new folder in the root directory, and see if you can access those without any problems - might narrow down where the problem is.