Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use .htaccess with php5.4 built-in server

Tags:

php

.htaccess

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

like image 368
Gildas Ross Avatar asked Sep 24 '12 11:09

Gildas Ross


People also ask

Is it possible to use htaccess with PHP?

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

How do I enable htaccess in Apache?

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?

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.

Is it possible to develop a PHP project without Apache?

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.


1 Answers

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.

like image 123
gearsdigital Avatar answered Nov 15 '22 13:11

gearsdigital