Malik Nabeel Malik Nabeel - 3 months ago 27
PHP Question

how to remove filename from URL?

I have a path like following

http://localhost/streamcola/watch/getvideo.php


I want to remove /getvideo.php and just want the following path

http://localhost/streamcola/watch


how can i do this.?
I not rewriting my URL , i just want to remove extension only.

Answer

File name removal is complex but its possible, but i do this by removing the extension of the file, As my Filename is getvideo.php and i want http://localhost/streamcola/watch So i change my file name to watch.php and remove that .php extension This is done by creating a new file named .htaccess file. I place it with my watch.php file and code of that .htyaccess file is following

RewriteEngine On

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]

and hence i get my desired URL..