sabecs
asked on
.htaccess redirecting link to home page
Hi,
I need help with my .htaccess file, all works well execpt if I try the following link
www.mywebsite.com.au/admin/view_upd_order.php?order_id=45
I get redirected to my home page
https://www.mywebsite.com.au/index.php
if I take out the 2 lines below all works OK but I lose the ability to force users to the SSL site?
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Any ideas what I am doing wrong?
Thanks for your help.
I need help with my .htaccess file, all works well execpt if I try the following link
www.mywebsite.com.au/admin/view_upd_order.php?order_id=45
I get redirected to my home page
https://www.mywebsite.com.au/index.php
if I take out the 2 lines below all works OK but I lose the ability to force users to the SSL site?
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Any ideas what I am doing wrong?
Thanks for your help.
SetEnv PHPRC /home/mywebsite/public_html
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.mywebsite.com.au$ [NC]
RewriteRule ^(.*)$ https://www.mywebsite.com.au/$1 [L,R=301]
RewriteRule ([0-9]+)(.*)\.html$ index.php?page_id=$1
ErrorDocument 404 http://www.mywebsite.com.au/index.php
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RedirectMatch permanent ^/show/?$ http://www.mywebsite.com.au/showme.php
RedirectMatch permanent ^/showme/?$ http://www.mywebsite.com.au/showme.php
My guess is that the forced SSL is rewriting the URL improperly, and it is then being picked up by the 404 rule. You'll need to turn on mod_rewrite's log functionality to verify what is actually being tested. Use "RewriteLogLevel 9" and post a single attempt to browse to the affected URL.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help, very much appreciated.
I tried RewriteLogLevel 9 but received a server config error.
www.mywebsite.com.au/admin/view_upd_order.php?order_id=45
I did notice that the admin directory is password protected and the .htaccess file contains the following,
AuthUserFile "/home/mywebsite/.htpasswd s/public_h tml/admin/ passwd"
AuthName "Admin's Only"
AuthType Basic
require valid-user
If I remove it then link appears to work ok, so would I need to also change this .htaccess file?
I tried RewriteLogLevel 9 but received a server config error.
www.mywebsite.com.au/admin/view_upd_order.php?order_id=45
I did notice that the admin directory is password protected and the .htaccess file contains the following,
AuthUserFile "/home/mywebsite/.htpasswd
AuthName "Admin's Only"
AuthType Basic
require valid-user
If I remove it then link appears to work ok, so would I need to also change this .htaccess file?
The RewriteLogLevel directive must go in the server or virtual host conf file. It can not be used in an htaccess file. Without access to the rewrite log, further troubleshooting will be difficult.
Is there anything else in the .htaccess file for the admin directory?
Does your other .htaccess file work for URL's that don't need access to the admin directory?
Does your other .htaccess file work for URL's that don't need access to the admin directory?
ASKER
Thanks again for your help, there is nothing else in the .htaccess file for the admin directory and all other folders and links appear to work ok.
I just tried http://www.mywebsite.com.au/admin & www.mywebsite.com.au/admin and both of these get redirected to https://www.mywebsite.com.au/index.php also, but https://www.mywebsite.com.au/admin is OK..
I just tried http://www.mywebsite.com.au/admin & www.mywebsite.com.au/admin and both of these get redirected to https://www.mywebsite.com.au/index.php also, but https://www.mywebsite.com.au/admin is OK..
When you go to http://www.mywebsite.com.au/admin are you prompted for a userid and password?
ASKER
If I got to http://www.mywebsite.com.au/admin I am not prompted for a password, just get redirected to home page, only get prompted if I use https://
Umm, I got to re-read. I thought that .htaccess files were supposed to processed "lowest" to highest", meaning if I had
/.htaccess
/admin/.htaccess
that the one in /admin would be processed first then the on in /. I would expect you to be prompted.
What happens if you specific the full "admin" url of the default page? Meaning something like /admin/index.php.
/.htaccess
/admin/.htaccess
that the one in /admin would be processed first then the on in /. I would expect you to be prompted.
What happens if you specific the full "admin" url of the default page? Meaning something like /admin/index.php.
ASKER
If I try www.mywebsite.com.au/admin/index.php or http://www.mywebsite.com.au/admin/index.php , same again gets redirected to https://www.mywebsite.com.au/index.php
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks giltjr, I tried your suggestion but same again...
ErrorDocument 404 http://www.mywebsite.com.au/index.php
To:
ErrorDocument 404 https://www.mywebsite.com.au/index.php
If you really want to force all traffic to https.