1

I am having problems with my .htaccess file.
It looks like this:

RewriteEngine On  

RewriteCond %{HTTP_HOST} ^website\.de [NC]  
RewriteRule ^(.*)$ http://www.website.de/folder/$1 [L,R=301]  

RewriteRule ^traffic/?$ traffic.php [NC,L]  
RewriteRule ^what-if/?$ whatif.php [NC,L]  

If I call www.website.de/folder/traffic I get www.website.de/folder/traffic/.
But if I call www.website.de/folder/what-if the trailing / is missing.

How can I add it everywhere?

Justin Iurman
  • 18,954
  • 3
  • 35
  • 54
flightsearch
  • 79
  • 2
  • 10

1 Answers1

0

You have to specify a RewriteBase since your htaccess is in a subfolder.
Also, you have to disable MultiViews option to avoid the problem you have.

Options -MultiViews

RewriteEngine On
RewriteBase /folder/

RewriteCond %{HTTP_HOST} ^website\.de$ [NC]  
RewriteRule ^(.*)$ http://www.website.de/folder/$1 [L,R=301] 

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

RewriteRule ^traffic/$ traffic.php [NC,L]  
RewriteRule ^what-if/$ whatif.php [NC,L] 
Justin Iurman
  • 18,954
  • 3
  • 35
  • 54
  • Thank you for your effort! Didn't work that way but pointed me to [link](http://stackoverflow.com/questions/704102/how-does-rewritebase-work-in-htaccess) this earlier question. Now i added this line `rewriteRule ^(([a-z0-9\-]+/)*[a-z0-9\-]+)$ $1/ [NC,R=301,L]` and this helped. could you maybe edit your answer and I will be happy to accept :) – flightsearch Jan 18 '15 at 22:19
  • Well what you asked was how to get `http://domain.com/folder/traffic` (without a trailing slash, just as `what-if` right ?). Because if you're now adding trailing slash, you have to add something in my code – Justin Iurman Jan 18 '15 at 22:22
  • I seemed to wrote it unclear. I wanted to have the trailing slash (think it looks neat). I edited my question. – flightsearch Jan 18 '15 at 22:24
  • No problem, my bad. You can see my edited answer which takes your comment into consideration – Justin Iurman Jan 18 '15 at 22:29