In my development environment, I use the web built-in web server of php5.4 but it seems that .htaccess doesn't work correctly. I can't found the doc of that server. Can someone tell me if it is possible to use htaccess and mod_rewrite like apache?
Thank you very much
You can't use .htaccess with PHP's built-in server. It is not supported. If you want to use .htaccess and not other way of configuring your webserver, then you either have to use Apache or parse .htaccess yourself in PHP (that probably would be a difficult thing) – Agares Dec 9 '14 at 15:45
By default, the . htaccess file is not enabled. 1. Open the default host configuration file by entering the following command in the terminal: 2. Locate the section labeled <Directory /var/www>. Save the file and exit. 3. Next, restart the Apache service:
What is an htaccess File? The .htaccess file in Apache is a tool that allows configurations at the directory and subdirectory level. Using . htaccess enables you to configure website permissions without altering server configuration files.
While developing a project, PHP built-in server is much more flexible and easy to use compared to desktop setups like LAMP, XAMP, WAMP, etc. However, without Apache, you also lose access to the magical and powerful .htaccess feature where you can create simple rewrite rules.
As in my comment mentioned, the current directory is by default your webroot. Also this webserver doesn't support .htaccess
.
You'll find a good explanation about your issues here.
Get the Server Running
By default, the current directory is your webroot and you can now request whatever files are here, and run PHP in the usual way
or
Routing Requests Like Apache Rewrite
One immediate feature that I was looking for was the ability to redirect all incoming requests to index.php, which I usually do with an .htaccess file. This webserver doesn't support those (although my good friend Josh has created something pretty close) but it does support a routing file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With