A question about rewriting

WBOY
Release: 2016-07-29 09:15:41
Original
1220 people have browsed it

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.


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!