Jump to content

Recommended Posts

Hello Guys,

 

I written code for adding trailing slash using htaccess. code as below.

 

RewriteEngine On
Options +FollowSymlinks

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !example.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$   /$1/ [L,R=301]

RewriteRule ^index/$ index.php

 

This code is perfectly working xamp local server. 

 

http://www.domain.com/index/      -  executes http://www.domain.com/index.php

 

But when i upload files on live linux server. it does not work. because index.php available on server like same name not work. If i make it.

 

RewriteRule ^home/$ index.php

 

then it will work on server.

 

http://www.domain.com/home/      -  executes http://www.domain.com/index.php

 

It means, the same file name exists then not work.

 

Please help on this. what is the problem. any rewrite condition to resolve this problem.

 

Link to comment
https://forums.phpfreaks.com/topic/275431-adding-trailing-slash-using-htaccess/
Share on other sites

So it worked? Great.

 

MultiViews allows you to omit extensions from existing files, so with it enabled /index will be automatically translated to index.php. By the time mod_rewrite and your RewriteRule kicks in, the request has already been "rewritten" to /index.php, the REQUEST_FILENAME !-f will not be true, and your URL rewriting will not trigger.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.