0

I've got an issue when I'm trying to add a trailing slash to non existent files. Here is my rewrite rules

# remove www from url
RewriteCond %{HTTP_HOST} ^www.goautohub.com [NC]
RewriteRule ^(.*)$ http://goautohub.com/$1 [L,R=301]

#rewrite news/article name
RewriteRule ^news/([^/]*)/$ news.php?viewnews=$1 [NC,L]


#remove index from url
RewriteRule ^index\.php/?$ / [L,R=301,NC]

#remove php from url
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

The only thing left right now I want to do is rewrite this url

/news/mustang-cobra-model-highlights

to

/news/mustang-cobra-model-highlights/

If I use use something like

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

which I found from Force trailing slash at end of rewritten query string it works but it screws up all my other ones it there is already a trailing slash. What it does it adds

/.php/ to the end.

I figure I need a way to limit that to just the news page but I can't seem to get the rule right.

Community
  • 1
  • 1

1 Answers1

0

The followin rewrite rule should work:

RewriteRule ^/news/(.*)/$ /news/$1 [NC,L]
benjamin.d
  • 2,801
  • 3
  • 23
  • 35