简体   繁体   中英

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. ie,

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

How to do this?

Any help would be appreciated.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM