The Little Guy Posted February 28, 2007 Share Posted February 28, 2007 How can I remove the filename and file extention from a url? Where it looks something like this: http://youtube.com/watch?v=cio9b0-v0Mo Or this: http://www.google.com/search?q=mod+rewrite Quote Link to comment https://forums.phpfreaks.com/topic/40609-remove-file-name-and-extention/ Share on other sites More sharing options...
cxer Posted March 1, 2007 Share Posted March 1, 2007 Hi The Little Guy To remove the file name and its extention, you have to write php script or use mod_rewrite module. I want to show you mod_rewrite,apache module.To use this module you have a apache server,and there is a .htaccess file your host. You modify this file to change URLs.You can write and examine that rules , RewriteEngine On RewriteBase / RewriteRule ^school/images/(.*)$ images/$1 RewriteRule ^school/(.*).html index.php?id=$1 After this rule you can use www.xxx.com/school/1.html so you hide your .php extension if you want remove extensions complately,use that RewriteEngine On RewriteBase / RewriteRule ^(.*) index.php?id=$1 then you can use www.xx.com/1 for example. take care,bye Quote Link to comment https://forums.phpfreaks.com/topic/40609-remove-file-name-and-extention/#findComment-196476 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.