Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 967 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

.htaccess Simple Rewrite Question

Thread title: .htaccess Simple Rewrite Question
Closed Thread    
    Thread tools Search this thread Display Modes  
08-25-2006, 03:35 AM
#1
Sketch is offline Sketch
Sketch's Avatar
Status: Member
Join date: Aug 2005
Location: Melbourne, Australia
Expertise:
Software:
 
Posts: 419
iTrader: 0 / 0%
 

Sketch is on a distinguished road

  Old  .htaccess Simple Rewrite Question

G'Day,

I'm working on a site and I want to redirect users in the following fashion;

If they visit http://www.site.com/payment or http://site.com/payment

I want to redirect them to https://www.site.com/payment

I'm sure its possible I just don't know how to do it.

Also I have this code

Code:
RewriteRule ^about/$ about [R]
Which should just get rid of the slash off the address name but it doesn't. It redirects the user to;

http://www.site.com/home/myusername/public_html/about/

Which is not correct. Does anyone know how to fix this?

Thank You!

08-25-2006, 03:40 AM
#2
Garrett is offline Garrett
Status: Waving
Join date: Aug 2005
Location:
Expertise:
Software:
 
Posts: 2,694
iTrader: 11 / 100%
 

Garrett is on a distinguished road

Send a message via MSN to Garrett

  Old

You could also, just put a index.php file in the payment folder of www.site.com like:
PHP Code:
<?php
header
("Location: https://www.site.com/payment/");
?>

08-25-2006, 03:47 AM
#3
MaxS is offline MaxS
Status: Senior Member
Join date: Aug 2005
Location: New York
Expertise:
Software:
 
Posts: 825
iTrader: 1 / 100%
 

MaxS is on a distinguished road

  Old

Code:
 RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain\.com/payment$ [NC]
RewriteRule ^(.*)$ http://domain.com/payment$1 [R=301,L]
Maybe?

08-25-2006, 01:48 PM
#4
Sketch is offline Sketch
Sketch's Avatar
Status: Member
Join date: Aug 2005
Location: Melbourne, Australia
Expertise:
Software:
 
Posts: 419
iTrader: 0 / 0%
 

Sketch is on a distinguished road

  Old

Thanks MaxS. My only problem is I already use Rewrite so will putting RewriteCond in there cause any issues?

Also Garrett, wouldn't have cause a permanent loop?

08-25-2006, 02:40 PM
#5
iisbum is offline iisbum
iisbum's Avatar
Status: Member
Join date: Oct 2005
Location: Clifton Park, NY, USA
Expertise:
Software:
 
Posts: 273
iTrader: 4 / 100%
 

iisbum is on a distinguished road

  Old

I would do that in two seperate steps.

Why not have all traffic for site.com, redirect to www.site.com (better for search engine rankings). You're probably worried here since the SSL certificate is for www.site.com, and not for site.com, but better to redirect all traffic I think.

Then in the payment page I would add the https check in the php as someone previously described. You can also do the https check just for that page with rewrite rules, I found this link which should be helpful:
http://www.whoopis.com/howtos/apache-rewrite.html

Cheers,
Mubs

08-25-2006, 03:08 PM
#6
MaxS is offline MaxS
Status: Senior Member
Join date: Aug 2005
Location: New York
Expertise:
Software:
 
Posts: 825
iTrader: 1 / 100%
 

MaxS is on a distinguished road

  Old

Originally Posted by Sketch
Thanks MaxS. My only problem is I already use Rewrite so will putting RewriteCond in there cause any issues?

Also Garrett, wouldn't have cause a permanent loop?
I think it will work. Your best bet is to try it. I'm not a mod_rewrite expert.

08-25-2006, 10:56 PM
#7
Garrett is offline Garrett
Status: Waving
Join date: Aug 2005
Location:
Expertise:
Software:
 
Posts: 2,694
iTrader: 11 / 100%
 

Garrett is on a distinguished road

Send a message via MSN to Garrett

  Old

Originally Posted by Sketch
Thanks MaxS. My only problem is I already use Rewrite so will putting RewriteCond in there cause any issues?

Also Garrett, wouldn't have cause a permanent loop?
How? https and http would be 2 different pages right :S

08-25-2006, 11:43 PM
#8
Sketch is offline Sketch
Sketch's Avatar
Status: Member
Join date: Aug 2005
Location: Melbourne, Australia
Expertise:
Software:
 
Posts: 419
iTrader: 0 / 0%
 

Sketch is on a distinguished road

  Old

Originally Posted by iisbum
I would do that in two seperate steps.

Why not have all traffic for site.com, redirect to www.site.com (better for search engine rankings). You're probably worried here since the SSL certificate is for www.site.com, and not for site.com, but better to redirect all traffic I think.

Then in the payment page I would add the https check in the php as someone previously described. You can also do the https check just for that page with rewrite rules, I found this link which should be helpful:
http://www.whoopis.com/howtos/apache-rewrite.html

Cheers,
Mubs
Having the www and no-www shouldn't effect SEO should it? Anyway, I checked out the whoopis.com site and it was helpful as I found out a few things but I followed what they said and I only managed to redirect traffic from http://site.com/payment to http://www.site.com/payment/ (Notice the slashes at the end) It would only redirect traffic without a slash and it still wouldn't move them to the HTTPS.

I think I might have to do some more hunting...

Originally Posted by MaxS
I think it will work. Your best bet is to try it. I'm not a mod_rewrite expert.
I tried out your code and it worked the same as the above one. It just put a slash on the end and moved them to the www version. Still no HTTPS no matter how much I change it

Originally Posted by Garrett
How? https and http would be 2 different pages right :S
I have seen this on some servers, different folders are setup httpsdocs and httpdocs. Unfortunately my server uses the one file for both versions

08-28-2006, 01:57 PM
#9
iisbum is offline iisbum
iisbum's Avatar
Status: Member
Join date: Oct 2005
Location: Clifton Park, NY, USA
Expertise:
Software:
 
Posts: 273
iTrader: 4 / 100%
 

iisbum is on a distinguished road

  Old


Having the www and no-www shouldn't effect SEO should it?
Very much so, espically for Google. Google treats the 2 pages as distinct urls, so seeing the same content on both can result in duplicate content penalties, and having 2 urls may affect your page rank. If people link to different urls, ie, the one with the www has one page rank, and the one without the www has its own page rank. If you setup the redirecting correctly, you'd get a combined rank based on all the links.


Anyway, I checked out the whoopis.com site and it was helpful as I found out a few things but I followed what they said and I only managed to redirect traffic from http://site.com/payment to http://www.site.com/payment/ (Notice the slashes at the end) It would only redirect traffic without a slash and it still wouldn't move them to the HTTPS.
If you post the htaccess rules you're using now I should be able to help you figure what's wrong...

Mubs

08-29-2006, 12:20 PM
#10
Sketch is offline Sketch
Sketch's Avatar
Status: Member
Join date: Aug 2005
Location: Melbourne, Australia
Expertise:
Software:
 
Posts: 419
iTrader: 0 / 0%
 

Sketch is on a distinguished road

  Old

Thanks for that Mubs.

I think I will change over the htaccess file so that only www. versions of my site can be found

I also fixed up the SSL thing. Someone sent me this code.

Code:
if($_SERVER['ssl_access'] != 1 && $_SERVER['HTTPS'] != on)
header("Location: https://www.yourdomain.tld/$_SERVER[SCRIPT_URL]");
Thanks for all your help

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed