I'd like to extract the .php extension from our URL's and so far, I've been using: RewriteEngine On RewriteRule ^new-url$ new-url.php [L] RewriteRule ^new-url2$ new-url2.php [L] Code (markup): I've tried using a wildcard before but it messed up with some files I did wanted to keep the extension. Now I thought I could use a wildcard for every .php5 file, and then rename the files I'd like to have the extension extracted. Would that work? If so, what should I put inside my .htaccess?
I am not an expert, but this might work for you: RewriteEngine On RewriteRule ^(.*)$ /$1.php [NC,QSA,L] Code (markup): Just make sure the name of the directory is the same as the name of your php file.
Thanks for your answer baumann! So if I use the following code: RewriteEngine On RewriteRule ^(.*)$ /$1.php5 [NC,QSA,L] Code (markup): I would extract the extension from every URL ending with .php5? (eg. www.domain.com/file.php5 to www.domain.com/file)
When you write your urls, you would use something like: http://domain.com/my-super-directory/ Code (markup): notice the trailing forward slash. the mod_url will rewrite it to: http://domain.com/my-super-directory.php Code (markup): there is a small modification to the code I gave you: RewriteEngine On RewriteRule ^(.*)/$ /$1.php [NC,QSA,L] Code (markup): notice the forward slash just before the first $ sign.
Thanks for your answer baumann, but I would like to extract the extension from every URL ending with .php5 and make a 301 redirect if people access it with .php (eg. www.domain.com/file.php5 to www.domain.com/file). What code should I use to accomplish that? Does anyone else know?