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.
Related
I want to cancel an .htaccess rewrite that redirects people from mysite.com to mysite.com/blog.
I previously wanted to bypass the main page and send users straight to a subdirectory, so I added a rewrite. Now I want people to be able to access mysite.com, but still be able to reach mysite.com/blog (but only when they follow a link to mysite.com/blog, not by default). I'm a beginner to .htaccess, so I appreciate the patience and help.
Here's what was in my .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?dreamybeast.design$
RewriteRule ^(/)?$ blog [L]
I thought that just commenting out my rewrite code in the .htaccess file would stop the site from redirecting mysite.com to mysite.com/blog, but I'm still not able to land on mysite.com at all.
I also tried deleting the .htaccess file (there was nothing else in it) and I still can't land on the root url.
--- edit ---
There's an .htaccess file in the blog subfolder (which contains a Wordpress install) with the following code in it:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
Is it possible that this is what's causing the redirect, not the .htaccess file in the root?
I need to rewrite an url like /services/rental/faq-2/ so that the user (and robots) see /services/rental/faq/
This is my current .htaccess (it's Wordpress) with no successful rewrite:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^/services/rental/faq/?$ /services/rental/faq-2/ [NC,L]
</IfModule>
# END WordPress
Any of the hints I searched actually worked, maybe rule order is important or (most probable) I have no idea on how to do it
Your external URL is /services/rental/faq[/]. This is the one produced by links in your pages, and is the one robots and users see. It is NOT produced by .htaccess -- .htaccess only sees incoming URIs.
Try moving your new RewriteRule up before all the other WordPress RewriteRules (after the RewriteBase).
I got a problem with my .htaccess here and altough I searched the web and tried many things, I could not find any solution...
I have a wordpress-installation with enabled permalinks. Additional to that, I need to rewrite another URL on this wordpress-installation, which does not belong to WP.
If a user browses to http://www.URL.com/?page_id=30&tag=all&filterCategory=6\%23Jackets, I'd like to show http://www.URL.com/jackets.html as URL. There should also be the possibility to directly browse to http://www.URL.com/jackets.html.
My .htaccess looks like this
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^jacket\.html$ http://www.URL.com/?page_id=30&tag=all&filterCategory=6\%23Jackets [L]
</IfModule>
# END WordPress
Does anyone have any idea why this does not work?
The WordPress rewrite rules are redirecting any requests to non-existant files through WordPress. The rewrite rule responsible for this, RewriteRule . /index.php [L], is marked with [L], indicating that no more rules are to be processed after it. In order for your rule to work, it must be placed before the WordPress rules, but after the line RewriteBase /.
I have a website built on codeigniter and am trying to get the PP IPN working with it. I have looked at a few CI specific libraries, but want to have a stand alone IPN file.
Basically, I have CI installed in the website root and I have another directory 'pp', also in the root.
I'm trying to test the IPN using Paypal's sandbox, but it's returning a 404, I also can't access the file directly.
Here is my .htaccess file:
XSendFile on
Options -Indexes
Options +FollowSymlinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
### Canonicalize codeigniter URLs
RewriteRule ^(index(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
RewriteCond %{HTTP_HOST} !^(www) [NC]
RewriteRule ^(.*)$ http://www.mysite.net/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|pp|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
</IfModule>
Here's hoping it's something really obvious!
Thanks,
Ryan
If the pp directory exists, you could just put an htaccess file in that directory and just have:
RewriteEngine On
in it by itself, and any rules in the main htaccess file would get ignored. If your paypal stuff already has rewrite rules in an htaccess file in the pp directory, you may want to look into those rules as the cause of the 404.
Do you have mod_rewrite.c enabled. If not, that .htaccess will always give 404. (Sorry I couldn't make this a comment, don't have the rep).
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /homepage/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /homepage/index.php [L]
</IfModule>
That is my .htaccess code. I have created new file in homepage/test.php and when i visit it from browser it give error of access,
i have tried by replacing index.php with test.php but it still not working.
Can some one explain me how this code work and why not my code is working.
i have deleted .htaccess but its still not working. What else file it can be.
Change
RewriteRule . /homepage/index.php [L]
to:
RewriteRule (.+) /homepage/index.php?page=$1 [L]
P.S. For this to work, your index.php needs to listen for $_GET['page'] and load the appropriate resource.
EDIT: without using the "?page=$1" your code will just display the index page for all requests that are not files or directories. I am not sure if that is what your were going for.