views:

45

answers:

3

My current .htaccess file looks like this:

RewriteEngine on
RewriteBase /

Options +FollowSymLinks -Indexes

RewriteRule ^video/(.*)$ video.php?id=$1 [L]
RewriteRule ^video/(.*)$([a-zA-Z0-9]+) video.php?id=$1 [L]
RewriteRule ^tag/(.*)/page-(.*)/$ tag.php?tag=$1&page=$2 [L]
RewriteRule ^tag/(.*)/page-(.*)$ tag.php?tag=$1&page=$2 [L]
RewriteRule ^tag/(.*)?$ tag.php?tag=$1
RewriteRule ^page/(.*)$ page.php?id=$1 [L]
RewriteRule ^feed feed.php [L]

i want to add a slash to all my url's

like this:

> example.com/video/video_id/
> 
> example.com/tag/keyword/
> 
> example.com/tag/keyword/page-2/      (3... and so on...)
> 
> example.com/page/name/
> 
> example.com/feed/

And i want to redirect my current links to the new slash url's

Can somebody help me, please?

+1  A: 

Your current htaccess file supports a trailing / although you probably would prefer

RewriteRule ^video/(.*)/$ video.php?id=$1 [L]

So that you don't have to handle the / in video.php

Just update all of your URLs to be example.com/video/video_id/ instead of example.com/video/video_id in whatever you are using (your framework/flat HTML files).

Your old URLs will still work. If you really want to redirect them, you can:

RewriteCond %{REQUEST_URI} ^video/ [NC]
RewriteRule ^video/(.*)$ video.php?id=$1 [L,R=301]

The [NC] means No-case checking (so /VIDEO) would work. The [R=301] means permanent redirect (useful for SEO).

Go through and expand for your other rules.

Edit:

Sorry, I don't think it was quite right before. Try the following:

RewriteEngine on
RewriteBase /

Options +FollowSymLinks -Indexes

RewriteCond %{REQUEST_URI} ^video/ [NC]
RewriteRule ^video/(.*)$ video/$1/ [L,R=301]
RewriteRule ^video/(.*)/$ video.php?id=$1 [L]

RewriteCond %{REQUEST_URI} ^tag/ [NC]
RewriteRule ^tag/(.*)/page-(.*)$ tag/$1/page-$2/ [L,R=301]
RewriteRule ^tag/(.*)/page-(.*)/$ tag.php?tag=$1&page=$2 [L]

...
Blair McMillan
A: 
RewriteEngine on
RewriteBase /
Options +FollowSymLinks -Indexes

RewriteRule ^video/(.*)/$ video.php?id=$1 [L]

RewriteCond %{REQUEST_URI} ^video/ [NC]
RewriteRule ^video/(.*)$ video.php?id=$1 [L,R=301]


RewriteRule ^tag/(.*)/$ tag.php?id=$1 [L]

RewriteCond %{REQUEST_URI} ^tag/ [NC]
RewriteRule ^tag/(.*)$ tag.php?id=$1 [L,R=301]


RewriteRule ^page/(.*)/$ page.php?who=$1 [L]

RewriteCond %{REQUEST_URI} ^page/ [NC]
RewriteRule ^page/(.*)$ page.php?id=$1 [L,R=301]


RewriteRule ^feed/ feed.php [L]

RewriteCond %{REQUEST_URI} ^feed/ [NC]
RewriteRule ^feed/ feed.php [L,R=301]

but i've still have problems ...

i don't know what to do with

RewriteRule ^video/(.*)$([a-zA-Z0-9]+) video.php?id=$1 [L]
RewriteRule ^tag/(.*)/page-(.*)$ tag.php?tag=$1&page=$2 [L]
Adrian
A: 

don't works

any other ideeas?

Adrian