1

I have created a new version of a website at in a secure https folder, I want any requests to go to that folder, so for example https://photofileltd.co.uk/index.php?page=services would then display https://secure.photofileltd.co.uk/new_site/index.php?page=services

I've tried this in .htaccess, it re-directs fine but does not change/mask the URL, updated thanks to Jan:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://secure.photofileltd.co.uk/new_site/$1 [L]

Any help or advice would be much appreciated - I'm not very familiar at all with htaccess/mod_rewrite, thank you!

Nick
  • 3,745
  • 20
  • 56
  • 75

2 Answers2

2

you are loosing the query on your way:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://secure.photofileltd.co.uk/new_site/$1 [L]
Jan
  • 42,290
  • 8
  • 54
  • 79
  • Many thanks, this seems to work great for me in Chrome, but not Firefox, hm! Maybe it's my machine. Is there a way to mask the URL also? :) – Nick Apr 19 '12 at 19:11
  • 1
    Yup, remove your 'R' flag. Have you tried closing FF as the redirects are stored some time. – Jan Apr 19 '12 at 19:16
  • Ah ha, I see, thank you! and thank you for the info on Firefox :) – Nick Apr 19 '12 at 19:18
  • Hm, I'm using your exact code as above (so no 'R' flag) but unfortunately it still is changing the URL, for example: http://photofileltd.co.uk/index.php?page=services – Nick Apr 19 '12 at 19:20
  • 1
    Hi Nick, there's still sth. wrong in your htaccess file. From what I understand, what you're trying to do is to redirect http content to https content in a folder called "new_site". Is that correct? This is where I'm redirected to when I click on the link you posted: https://secure.photofileltd.co.uk/new_site/secure/index.php?page=services I think "secure" should not be there, should it? – Jan Apr 19 '12 at 19:25
  • 1
    Thank you Jan - yes that's right, so http://photofileltd.co.uk/ -> https://secure.photofileltd.co.uk/new_site/ - I'm not sure if it's even possible? :$ – Nick Apr 19 '12 at 19:27
  • 1
    Is there sth. else in the htaccess? And do you have another on in the secure folder? Normally, this works flawlessly. Can you edit your original post in order to post the whole content of your htaccess file? – Jan Apr 19 '12 at 19:35
  • Thanks, I've just updated the original post (although my htaccess file is just exactly what you copid above!) - there is no sth. else, and there isn't a .htaccess file in the secure folder. Thanks again :) – Nick Apr 19 '12 at 19:36
  • 1
    Hi Nick, I've been a bit tired for I could have seen it earlier. For other domains (including subdomains) to be shown as "your domain" in the address bar, you will need the mod_proxy module (http://httpd.apache.org/docs/2.0/mod/mod_proxy.html). – Jan Apr 19 '12 at 19:48
  • D'oh - thank you! I will speak with the hosts, hopefully they can install it :-) Thank you so much for all of your help – Nick Apr 19 '12 at 19:49
1

Try

RewriteRule ^ https://secure.photofileltd.co.uk/new_site%{REQUEST_URI} [R=301,L]

simshaun
  • 21,263
  • 1
  • 57
  • 73
  • Many thanks, I've updated the original post with my new code, but unfortunately now it just goes a bit crazy: http://photofileltd.co.uk – Nick Apr 19 '12 at 19:05
  • 1
    Appears to be working for me. Give me a couple more links within the site to test. – simshaun Apr 19 '12 at 19:07
  • It is? For me it re-directs to https://secure.photofileltd.co.uk/new_site//new_site//new_site//new_site//new_site//new_site//new_site//new_site//new_site//new_site//new_site//new_site//new_site//new_site//new_site//new_site//new_site//new_site//new_site//new_site// (you get the idea) – Nick Apr 19 '12 at 19:09
  • Interestingly it works perfectly in Chrome, but not Firefox :/ Also, optimistic - but is there a way to mask the URL? – Nick Apr 19 '12 at 19:09