URL Rewrite Problem of ThinkPHP

  • 2021-07-02 23:43:56
  • OfStack

All I want is to remove index. php from the URL path

The first is configuration.htaccess


<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

Because I am deployed on apache, I need to find LoadModule rewrite_module modules/mod_rewrite in the httpd. conf configuration file. so remove the preceding # and find AllowOverride None instead of AllowOverride All.

It is valid to access localhost/product now, but the path obtained by __APP__ or __URL__ or U contains index.php, that is, localhost/index.php. There is still one step left, which needs to be modified or added 'URL_MODEL' = in conf/config.php > 2,

And because I tried to deploy conist Enterprise Edition 2.0 based on ThinkPHP, there is such a configuration 'URL_MODEL' = in config. php > C ('TOKEN.false_static'), and the value of TOKEN.false_static is set to 1 at initialization, so. . . Mode 1 straight or 1, PATHINFO mode.

Deployed in Sina SAE, it does not support. htaccess, but only supports its own configuration file config. yaml, so add the following rewrite format code in config. yaml:


handle:
- rewrite: if(!is_dir() && !is_file() && path~"^(.*)$") goto "index.php/$1"


Related articles: