Jump to content


Photo

adding trailing slash using htaccess

htaccess

  • Please log in to reply
3 replies to this topic

#1 vishal.angre

vishal.angre

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 09 March 2013 - 12:57 AM

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.co...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.co....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.

 



#2 requinix

requinix

    Hopeless Member

  • Moderators
  • 5,914 posts
  • LocationWA

Posted 09 March 2013 - 02:28 AM

Try without MultiViews too.
Options +FollowSymLinks -MultiViews


#3 vishal.angre

vishal.angre

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 11 March 2013 - 02:18 AM

Thank you very much requinix.. :)



#4 requinix

requinix

    Hopeless Member

  • Moderators
  • 5,914 posts
  • LocationWA

Posted 11 March 2013 - 03:39 AM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com