I made a simple php framework and used & quot ;? The url view in the form of varval1 & amp; var2val2 & quot; is loaded normally. In apache, to beautify the url, use. the htaccess rule hides the index. php uses the url in pathinfo format. The page and data can be loaded, but css, js... I made a simple php framework and used"
?var=val1&var2=val2
"Url view loading is normal,
apache
To beautify the url, use
Hide index. php by using the. htaccess rule
And
Use pathinfo format
The url, page, and data can be loaded, but the path of css and js files is changed to the pathinfo format.
url
/
public/css/style.css
The loading path of css and js is incorrect. Find a correct. htaccess rule to load the Style File correctly.
Current error:
The project framework is placed under the capframework folder under the root directory of the site,
Usehttp://127.0.0.1/capframework/
Access all OK, css load OK,
css url
Is:http://127.0.0.1/capframework/public/css/captain.css
When usinghttp://127.0.0.1/capframework/article/list/tag/php
During access, css and js problems occur, and the path becomes
http://127.0.0.1/capframework/article/list/tag/public/css/captain.css
Currently, the following rules are used:
RewriteEngine on RewriteCond % {REQUEST_FILENAME }! -D RewriteCond % {REQUEST_FILENAME }! -F RewriteRule ^ (. *) $ index. php/$1 [QSA, PT, L]
Ask experts for advice and solve the problem
Reply content:
I made a simple php framework and used"?var=val1&var2=val2
"Url view loading is normal,
apache
To beautify the url, useHide index. php by using the. htaccess rule
AndUse pathinfo format
The url, page, and data can be loaded, but the path of css and js files is changed to the pathinfo format.url
/public/css/style.css
The loading path of css and js is incorrect. Find a correct. htaccess rule to load the Style File correctly.
Current error:
The project framework is placed under the capframework folder under the root directory of the site,
Usehttp://127.0.0.1/capframework/
Access all OK, css load OK,
css url
Is:http://127.0.0.1/capframework/public/css/captain.css
When usinghttp://127.0.0.1/capframework/article/list/tag/php
During access, css and js problems occur, and the path becomes
http://127.0.0.1/capframework/article/list/tag/public/css/captain.css
Currently, the following rules are used:
RewriteEngine on RewriteCond % {REQUEST_FILENAME }! -D RewriteCond % {REQUEST_FILENAME }! -F RewriteRule ^ (. *) $ index. php/$1 [QSA, PT, L]
Ask experts for advice and solve the problem
This is not a problem with. htaccess. The reference to css in your code is similar to this:
Then, when your page path ishttp://127.0.0.1/capframework/article/list/tag/php
The css path that the browser considers to be under the current directory and splicedpublic/css/captain.css
, So it becomeshttp://127.0.0.1/capframework/article/list/tag/public/css/captain.css
.
So you need
But this is still wrong, because the browser will think that the css path strength ishttp://127.0.0.1/public/css/captain.css
.
Therefore, you also need to manually add the root directory
However, the root directory is generally not a definite thing, so it needs to be changed. Almost all php frameworks provide such variables.
No. ht file errors: when the file corresponding to the link exists, the returned file is limited. When the file cannot be accessed directly through the link, the relevant rules will be matched.
The initialization file should contain WEB_ROOT, which is written in the template file.
{WEB_ROOT} / public/css/captain.css
It should be OK.
The css path is declared incorrectly. method 1, in
Statement Is the Basic path settings. Method 2: Use the absolute path when referencing css, as shown in figure
$ BaseUrl should be http: // 127.0.0.1/capframework/public/
In addition, for the sake of security ,. htaccess should be placed under public. If you configure a virtual host, it should also point to/capframework/public instead of/capframework, so as to avoid exposing other code. Of course, index. php should also be under public.
Upstairs !! Add'/'You can.