# Rewrite or return directives for discuz v3.1

**URL:** <https://www.ruby-forum.com/t/rewrite-or-return-directives-for-discuz-v3-1/237869>\
**Category:** NGINX\
**Created:** [December 4, 2013, 8:55am UTC](https://www.ruby-forum.com/t/rewrite-or-return-directives-for-discuz-v3-1/237869 "2013-12-04T08:55:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [December 4, 2013, 8:55am UTC](https://www.ruby-forum.com/t/rewrite-or-return-directives-for-discuz-v3-1/237869/1 "2013-12-04T08:55:02Z")

</div>

hello;  
I want to write a block to put in my VHOST config file.  
i want

1. if there is “/install/index.php/” in the link. it shouldbe removed  
from  
the link.
2. if the format is like /uc\_server/blab.php/uc\_server/blahblah ===it  
should change to===\>/uc\_server/blabal

what should I put in my VHOST config file and where?

my current VHOST format is :

```auto
server {
    server_name www.DOMAINNAME;
    rewrite ^(.*) http://DOMAINNAME$1 permanent;
}

server {
        listen 80;
        server_name DOMAINNAME;
                root /var/www/DOMAINNAME/htdocs;
                index index.php;
    include /etc/nginx/security;

# Logging --
access_log /var/log/nginx/DOMAINNAME.access.log;
error_log /var/log/nginx/DOMAINNAME.error.log notice;

        # serve static files directly
        location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
            access_log off;
            expires max;
        }

        location ~ \.php$ {
    try_files $uri =404;
                fastcgi_pass unix:/var/run/php5-fpm/DOMAINNAME.socket;
                fastcgi_index index.php;
                include /etc/nginx/fastcgi_params;
        }
}
```

Posted at Nginx Forum:

> **[rewrite or return directives for discuz v3.1](https://forum.nginx.org/read.php?2,245192,245192#msg-245192)**
>
> hello; I want to write a block to put in my VHOST config file. i want 1. if there is "/install/index.php/" in the link. it shouldbe removed from the link. 2. if the format is like /uc\_server/blab.php/uc\_server/blahblah ===it should change...

---

<div class="post-metadata">

**Author:** ![r004](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/439d5e/32.png) [@r004](https://www.ruby-forum.com/u/r004)\
**Post date:** [December 4, 2013, 12:48pm UTC](https://www.ruby-forum.com/t/rewrite-or-return-directives-for-discuz-v3-1/237869/2 "2013-12-04T12:48:15Z")

</div>

On 4 December 2013 07:54, r004 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> hello;  
> I want to write a block to put in my VHOST config file.  
> i want
> 
> 1. if there is “/install/index.php/” in the link. it shouldbe removed from  
> the link.
> 2. if the format is like /uc\_server/blab.php/uc\_server/blahblah ===it  
> should change to===\>/uc\_server/blabal
> 
> what should I put in my VHOST config file and where?

What part are you having difficulties with?

Have you read the documentation for “location” and “rewrite”? Have a  
read of that, and then let us know if you’re still having a problem.

J

---

<div class="post-metadata">

**Author:** ![r004](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/439d5e/32.png) [@r004](https://www.ruby-forum.com/u/r004)\
**Post date:** [December 4, 2013, 9:54pm UTC](https://www.ruby-forum.com/t/rewrite-or-return-directives-for-discuz-v3-1/237869/3 "2013-12-04T21:54:01Z")

</div>

On Wed, Dec 04, 2013 at 02:54:30AM -0500, r004 wrote:

Hi there,

> 1. if there is “/install/index.php/” in the link. it shouldbe removed from  
> the link.

In the rewrite line, capture the parts before and after  
/install/index.php/, and rewrite to those parts without the middle bit.

> 1. if the format is like /uc\_server/blab.php/uc\_server/blahblah ===it  
> should change to===\>/uc\_server/blabal

What does “format is like” mean? urls that start with something, or that  
end with something, or that include a specific pattern somewhere?

Which parts of the input are used to make the output?

If you can write down how the matching should happen, the rewrite rule  
should become clear.

[http://nginx.org/r/rewrite](http://nginx.org/r/rewrite)

## f

Francis D. removed\_email\_address@domain.invalid
