Home  >  Article  >  Backend Development  >  A question about rewriting

A question about rewriting

WBOY
WBOYOriginal
2016-07-29 09:15:411163browse

I made a website before and used rewriting to achieve pseudo-static. Today I want to add a blog function, but I found a problem. The previous rewriting rewritten "(w)/", and now / blog/ also cannot be opened, because the system does not treat /blog/ as an access to a folder, but as a parameter in the rewrite. I was already trembling about the rewrite, so I searched for a long time and finally found one. Method, record it and make a note:

# Do not rewrite the subdirectory directory

RewriteEngine On RewriteBase /
RewriteCond %{REQUEST_URI} ^/subdirectory/(.*)$
RewriteRule ^. *$ - [L]


RewriteEngine on RewriteBase /
RewriteRule ^$ app/webroot/ [L]​
​ RewriteRule ​ (.*) app/webroot/$1 [ L]


Add one more example:
# Do not forward directories or files with google prefix

RewriteEngine On RewriteBase /
Rewrite Cond %{REQUEST_URI} ^/google( .*)$
RewriteRule ^.*$ - [L]



RewriteEngine on RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (. *) app/webroot/$1 [L]


The above introduces an issue about rewriting, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn