wp-admin not working: server says my realm - wordpress

Installed a fresh Wordpress Website. on clicking http ://mysite.com/wp-admin instead of showing wordpress login page, it shows auth entication required:-
Why may this be?
edit:- my .htaccess file. I don't think it password protects my wp-admin.
rewriteengine on
RewriteCond %{REQUEST_URI} ^.*wp\-login\.php.*$
RewriteCond %{HTTP_COOKIE} !^.*admin_authenticated\=yes.*$
RewriteCond %{REQUEST_URI} !^.*auth.php.*$
rewriterule ^(.*)$ /auth.php?red=%1 [R,L]
rewriterule ^.*auth.php.*$ - [PT]
# 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]
</IfModule>
# END WordPress

remove all this
rewriteengine on
RewriteCond %{REQUEST_URI} ^.*wp\-login\.php.*$
RewriteCond %{HTTP_COOKIE} !^.*admin_authenticated\=yes.*$
RewriteCond %{REQUEST_URI} !^.*auth.php.*$
rewriterule ^(.*)$ /auth.php?red=%1 [R,L]
rewriterule ^.*auth.php.*$ - [PT]
admin_authenticated is requiring a password! And I assume you haven't set up a password yet, or you tried the one you set it up as with username and password, and it didn't work.
So remove all that.

Related

Rewrite domain to cut its URI

I need to set up the http://domain.com/wp1/ to be shown like http://domain.com/
I have tried to set up any rewrite in the past hours, but no success :(
P.S. There is a wordpress installed in the public_html/wp1, configured to work on http://domain.com/wp1/ URL. Its .htaccess is as follows:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp1/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp1/index.php [L]
</IfModule>
# END WordPress
Thanks in tons!
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain-name.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain-name.com$
RewriteCond %{REQUEST_URI} !folder/
RewriteRule (.*) /folder/$1 [L]
Changing the document root for the domain does the job.

How to move WordPress form HTTP to HTTPS

I have following code in my .htaccess file of a wp site
# 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]
</IfModule>
# END WordPress
I have done all the thing need for a WordPress site to operate in HTTPS now my site is opening in both the format i.e in HTTP and HTTPS, but if the user type example.com it goes to http not in https so to solve this I add few more code to solve this issue
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.yoursite.com [NC]
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [L,R=301,NC]
# 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]
</IfModule>
# END WordPress
but after adding this my site in not opening it says "ERR_TOO_MANY_REDIRECTS"
How to solve this issue, I want the user to go directly to https
The problem is that you're not checking if https is being used, so it just constantly tells the browser to go to https://www.yoursite.com/$1.
You can use %{HTTPS} to check whether the request uses https.
RewriteEngine on
RewriteCond %{HTTPS} !^on$ [NC]
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [L,R=301,NC]

Redirect all Wordpress pages to SSL apart from one

I want to redirect all pages on my Wordpress website to SSL apart from one.
I have tried numerous ways to do this and have succeessfully got the SSL working, but I cannot get the single page exclusion to work.
I am assuming the problem lies with the Wordpress specific rewrites.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{REQUEST_URI} ^parent-page/child-page/
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</IfModule>
# END WordPress
Any suggestions?
You always need your rules that redirect to be before the rules that internally rewrite. Otherwise, internal stuff (like /index.php) end up getting redirected.
Try:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{REQUEST_URI} !^/parent-page/child-page/
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteCond %{REQUEST_URI} ^/parent-page/child-page/
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Note that you also need to add a / leading slash to your %{REQUEST_URI} conditions, those will always start with a /. Additionally, you need to not redirect to https with that URI, so you need to add a negative exclusion condition to the redirect to https.

Redirect to a new domain & change url structure htaccess

I am trying to redirect a wordpress blog from an old domain to a new domain and changing the structure of the urls on the new domain.
So I want www.domainA.com to redirect to test.domainB.com/folder/
and www.domainA.com/2001/12/some-post to redirect to test.domainB.com/folder/some-post
This is what I currently have in my htaccess file. I have managed to achieve my second objective, but if you go to www.domainA.com, it does not redirect to test.domainB.com/folder/ All the other pages redirect properly aside from the homepage.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com$ [NC]
RewriteRule ^([0-9]+)/([0-9]+)/(.*)$ http://test.domainB.com/folder/$3 [R=301,NC,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I am sure I am missing something elemetary, but I can't seem to figure it out :(
Try this code :
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com$ [NC]
RewriteRule ^/?\d+/\d+/(.*)$ http://test.domainB.com/folder/$1 [NC,L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com$ [NC]
RewriteRule ^/?$ http://test.domainB.com/folder/ [NC,L,R=301]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /index.php [L]

htaccess and no www

I am trying to redirect my whole site to non-www
here is the htaccess code I am using
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# no www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.akorra\.com$ [NC]
RewriteRule ^.*$ http://akorra.com%{REQUEST_URI} [R=301,L]
any ideas
I think your rules need to between the module tags.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# no www
RewriteCond %{HTTP_HOST} ^www\.akorra\.com$ [NC]
RewriteRule ^.*$ http://akorra.com%{REQUEST_URI} [R=301,L]
# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
</IfModule>
Here is what you need to add to your .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
However, if you are working with Wordpress as the engine that powers your entire site, just update the permalink structure and all internal settings with your domain name in it to remove the www.
EDIT:
I thought that was different when I wrote the answer Sorry. Try moving your non www rule to the top...
# no www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.akorra\.com$ [NC]
RewriteRule ^.*$ http://akorra.com%{REQUEST_URI} [R=301s,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
AGAIN keep in mind if Wordpress is set to produce links with a www then nothing will stop it from reverting everything back to having a www even with a correct rewrite rule.
More Wordpress details:
Check the settings in wp/wp-admin/options-general.php ...
Be sure to remove the www in WordPress address (URL)
Be sure to remove the www in Blog address (URL)
AND then update your premalink structure in wp-admin/options-permalink.php so the changes are reflected.
After all that is said and done, be sure Wordpress did not overwrite new code in your .htaccess file.
Hi I think you need to adjust your script as follows for the rewriting to work:
Options +FollowSymlinks
RewriteEngine on
I believe that the follow symlinks absolutely has to be included for url rewriting to work properly.
More advice on mod_rewrite here:
http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html
Rob
RewriteEngine On
RewriteBase /
# no www
RewriteCond %{HTTP_HOST} ^([^.]+)\.akorra\.com$ [NC]
RewriteRule ^(.*)$ http://akorra.com/$1 [R=301,L]
# WordPres
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
This should work
I suggest to use this piece of code for removing www from your website:
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
it's more generic.
and in your example it's best to use this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# no www
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
</IfModule>

Resources