1

I am trying to figure those clean urls out again. I am trying to "convert"

http://www.website.com/videos.php?url=testurl

into

http://www.website.com/videos/testurl/

All of that works fine as long as I write the url without the / at the end. But for me it is really important to have the / at the end.

Here is my htaccess:

RewriteBase /
RewriteRule ^(.*)\/$ $1.php
RewriteRule videos/(.*)/?$ /videos.php?url=$1

Any help would be appreciated.

anubhava
  • 761,203
  • 64
  • 569
  • 643
Dennis
  • 595
  • 1
  • 6
  • 22

2 Answers2

1

Have it this way:

Options -MultiViews
RewriteEngine On
RewriteBase /

RewriteRule ^videos/([^/]+)/?$ videos.php?url=$1 [L,QSA,NC]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Thank you for that suggestion. I think we are getting closer. Now the get result is: testurl.php Is there any way i can change this to just testurl trhough the htaccess? – Dennis Feb 02 '16 at 22:25
  • What URL did you enter to test? also try updated rules. – anubhava Feb 02 '16 at 22:27
  • I tested it with www.domain.com/videos/testurl/ – Dennis Feb 02 '16 at 22:28
  • 1
    I am sorry buddy. I have had some other stuff in there. After i deleted it it works like a charm. Thank you so much! – Dennis Feb 02 '16 at 22:34
0

What you're looking for is rtrim:

$url = 'http://www.website.com/videos/testurl/';
$url = rtrim($url, '/');
wogsland
  • 9,106
  • 19
  • 57
  • 93
  • Thank you for that answer. I noticed that the get wil return testurl.php/testurl I know that i could use rtrim but i was wondering if there is a way that i will just get the return of testurl instead of the url above? – Dennis Feb 02 '16 at 22:09