wapmorgan
wapmorgan

Reputation: 131

Does php internal server read .htaccess configuration?

I have a .htaccess with some rewrite rules:

RewriteRule ^([a-zA-Z]+)\.page$ index.php?module=$1 [L]

When I launch php server with php -S 127.0.0.1:80 in current dir, http://127.0.0.1/home.page page is not found on my server. So I can understand that php internal server does not read RewriteRule's at least. Is it true or false?

Upvotes: 2

Views: 424

Answers (1)

GolezTrol
GolezTrol

Reputation: 116140

That is true. .htaccess is used and processed by Apache. Apache handles the requests. It just loads PHP as a helper to parse and execute PHP files. When PHP is started as a stand-alone server, it won't use those configurations.

You can check out this GitHub project for an .htaccess parser that can be used with PHP's built in server. Note though, that this project is an undefined state, somewhere between 'alpha' and 'abandoned'. This blog post links to that project too, and provides a little more context.

As a side note, PHP's internal server is not to be used as a production server. It doesn't have the power, flexibility, stability and security of a full fledged server like Apache or Nginx.

Upvotes: 1

Related Questions