How to run a file without extension as php
Hello,
I generally want to know if this is possible and if possible, how to do this.
I have a file search.php, I want to access it only from the url 'search', so I can't use the .htaccess code like Options +Multiviews. Any help would be appreciated
Thanks.
-
I generally want to know if this is possible and if possible, how to do this.
an htaccess rewriterule should work, like: RewriteRule ^([^\.]+)$ $1.php [NC,L]can't use the .htaccess code like Options +Multiviews.
why?0 -
I don't want users to access search.php, I only want them to access the file 'search', whereas multiviews allows access to users to search.php (with the php extension also). 0 -
You want the users to see site.com/search instead of site.com/search.php? 0 -
yes 0 -
no access to search.php with the php extension 0 -
A rewrite rule like the one below should work. RewriteRule ^([^\.]+)$ $1.php [NC,L] 0 -
Hello @rajeevacj, Let us know if the Mod_Rewrite rule suggestion helps. Thanks! 0 -
I am sorry for late reply, a glass of water spill on my laptop when I was to reply, so I needed some time to get it work. I fixed the issue myself. The code is the same, but it points to a single file i.e. search.php. .htaccess RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule search search.php [L]
search.php (at the top of the file) [PHP] == "/search") { } else { header("HTTP/1.1 404 Not Found"); exit(); } ?>[/PHP] I fixed it :)0 -
Glad that you have fixed it. 0
Please sign in to leave a comment.
Comments
9 comments