1

I want to get rid of the trailing slash from homepage by using htaccess.

My Actual URL was something like this

http://www.mydomain.com/iphone_index.php

I got rid of iphone_index.php from the URL by htaccess. The code I used to do this is --

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^.*/iphone_index.php
RewriteRule ^(.*)iphone_index.php$ $1 [R=301,L]

But I'm getting the result as

http://www.mydomain.com/

I want to get rid of this trailing slash. i.e.,

My Desired URL http://www.mydomain.com

How to do this?

Any help would be appreciated.

Alok Tripathi
  • 29
  • 1
  • 1
  • 7
  • is the `/` not added by the browser on client side? I believe browsers do that. Type `google.com` in your browser and you will see that it will change into `http://google.com/`. – Bazzz Mar 05 '12 at 10:58
  • That does not happen on my browsers though – Raintree Mar 05 '12 at 11:55
  • @Josh Hah, which browser is that? Notice that some modern browsers hide part of the url when the address bar doesn't have the focus. Try clicking in it after the page has loaded. – Bazzz Mar 05 '12 at 20:03
  • @Bazzz Firefox 10 and Chrome 17. I tried clicking in the address bar too. :) – Raintree Mar 05 '12 at 21:40
  • @Josh Hah, Indeed Firefox 10 doesn't show the full url neither after clicking, but if you copy and paste the url FROM the address bar TO some other place you will see that the browser pastes the full url rather than the partly hidden one. And then the "http://" and the trailing "/" will be visible. Internally the browser really uses `http://google.com/` rather than `google.com` that it shows to you in the address bar. – Bazzz Mar 06 '12 at 07:48

1 Answers1

1

You don;t need RewriteCond here so change your rule to this and clear your browser cache:

RewriteRule ^(.*)/iphone_index.php$ $1 [R=302,L]

Once you're sure it is working change R=302 to the R=301

anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Hi, thnx 4 ur quick reply. But ur soln even fails to remove **iphone_index.php** from the existing URL leave aside trailing slash. – Alok Tripathi Mar 05 '12 at 11:18