如何更正重写 nginx + apache url
how to correct rewrite nginx + apache urls
我有网站(前端 - nginx,后端 - (apache+php)),这是 nginx 配置文件
server {
listen *:80;
server_name website.plus www.website.plus;
access_log /var/log/nginx/access.log;
location / {
proxy_redirect off;
proxy_pass http://127.0.0.1:81/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 180;
}
}
阿帕奇
<VirtualHost 127.0.0.1:81>
ServerName website.plus
ServerAlias www.website.plus
ServerAdmin webmaster@localhost
DocumentRoot /var/www/website
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
并拥有此网址
website.plus/tag.php?tag=cat
website.plus/search.php?search_content=cat
website.plus/view.php?image=LhUId4avpxVZK
请帮助我,如何将 url 更改(重写)为
website.plus/tag/cat
website.plus/search/cat
website.plus/view/LhUId4avpxVZK
谢谢
试试这个(未测试):
rewrite ^tag.php?tag=(.*) tag/;
rewrite ^search.php?search_content=(.*) search/;
rewrite ^view.php?image=(.*) view/;
我认为很清楚(documentation of nginx's rewrite),但如果您有任何问题,请提问!
我有网站(前端 - nginx,后端 - (apache+php)),这是 nginx 配置文件
server {
listen *:80;
server_name website.plus www.website.plus;
access_log /var/log/nginx/access.log;
location / {
proxy_redirect off;
proxy_pass http://127.0.0.1:81/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 180;
}
}
阿帕奇
<VirtualHost 127.0.0.1:81>
ServerName website.plus
ServerAlias www.website.plus
ServerAdmin webmaster@localhost
DocumentRoot /var/www/website
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
并拥有此网址
website.plus/tag.php?tag=cat
website.plus/search.php?search_content=cat
website.plus/view.php?image=LhUId4avpxVZK
请帮助我,如何将 url 更改(重写)为
website.plus/tag/cat
website.plus/search/cat
website.plus/view/LhUId4avpxVZK
谢谢
试试这个(未测试):
rewrite ^tag.php?tag=(.*) tag/;
rewrite ^search.php?search_content=(.*) search/;
rewrite ^view.php?image=(.*) view/;
我认为很清楚(documentation of nginx's rewrite),但如果您有任何问题,请提问!