Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Help with mod_rewrite
October 18, 2006, 9:13 pm
rate this thread
In other words, I want to strip out the php extension
I tried putting in the .htaccess file the following:
But that didn't work at all.
So I tried with mod_rewrite:
RewriteRule /[^/\.]+$ %.php
It doesn't work either!!!
I need help please. What is the problem??
My hosting server is apache 1.3.37
Thanks in advance.
Re: Help with mod_rewrite
You could use the ForceType directive to serve PHP URLs without a file
extension. For example:
That would treat every file with no extension as a PHP script. On disk
the file path could be "/dir/file", and the URL would be "/dir/file".
Not sure if that's what you wanted. You can also use mod_rewrite in
this scenario. For example:
RewriteRule ^([^\.\?]+)(\?.*)?$ $1.php$2
That would internally convert incoming URLs that lacked a file
extension into .php requests. It would convert "file?a=b" into
"file.php?a=b". You would then create a script called file.php.
I think the ForceType way is probably easier. Is that what you needed?