Alok Tripathi
Alok Tripathi

Reputation: 29

Get rid of trailing slash from homepage by htaccess

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.

Upvotes: 1

Views: 428

Answers (1)

anubhava
anubhava

Reputation: 785196

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

Upvotes: 1

Related Questions