Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
SJ77 Posted April 14, 2017 Posted April 14, 2017 I want to give my members who contribute to downloads an easy URL to distribute. I am thinking it can be done with rewrites in the niginx config file but not sure how to make it work. For example how can I make https://invisionpower.com/adriano-faria/ lead to https://invisionpower.com/profile/114025-adriano-faria/content/?type=downloads_file help appreciated. Thank you
SJ77 Posted April 14, 2017 Author Posted April 14, 2017 I tried this location = /adriano-faria { return 301 https://invisionpower.com/profile/114025-adriano-faria/content/?type=downloads_file/ } it fails. Nginx won't boot until I remove this location block from the config file. ugh.. I can't get my finger on this.
Runar Posted April 18, 2017 Posted April 18, 2017 You simply forgot the semicolon on the second line location = /adriano-faria { return 301 https://invisionpower.com/profile/114025-adriano-faria/content/?type=downloads_file/; } In the future, you should test your nginx configuration before reloading or restarting nginx. I believe the test flag is -t: $ nginx -t
SJ77 Posted April 23, 2017 Author Posted April 23, 2017 HI However, I still can't make it work for the life of me Now my Nginx isn't crashing and -t passes but it doesn't work!!! Here is my whole nested set of blocks http { server { listen 80 default_server; server_name mysite.org www.mysite.org; location = /kyrakane { return 301 https://www.mystie.org/forum/index.php?/profile/49911-kyrakane/&tab=node_downloads_Files/; } } #more code for http block here omitted for this post } Shouldn't I be able to type www.mysite.org/kyrakane and get the link listed above? Thank you
sudo Posted April 23, 2017 Posted April 23, 2017 Do you want it to keep that path or just redirect? If its just redirect cant you use: rewrite ^/kyrakane/(.*) /forum/index.php?/profile/49911-kyrakane/&tab=node_downloads_Files/$1 permanent; rewrite ^/kyrakane /forum/index.php?/profile/49911-kyrakane/&tab=node_downloads_Files/ permanent; Use 1 of those, the first line is just to show how you can pass a path as a variable but I think the second is what you want. Just use that in your block at the top-ish area. No location needed.
SJ77 Posted April 24, 2017 Author Posted April 24, 2017 4 hours ago, ZeroHour said: Do you want it to keep that path or just redirect? If its just redirect cant you use: rewrite ^/kyrakane/(.*) /forum/index.php?/profile/49911-kyrakane/&tab=node_downloads_Files/$1 permanent; rewrite ^/kyrakane /forum/index.php?/profile/49911-kyrakane/&tab=node_downloads_Files/ permanent; Use 1 of those, the first line is just to show how you can pass a path as a variable but I think the second is what you want. Just use that in your block at the top-ish area. No location needed. I removed location to the above server block and added the second line in your example www.mysite.com/kyrakane leads to 404 error page. Still not working I fear
sudo Posted April 24, 2017 Posted April 24, 2017 Not sure why, I use those redirects in the server block under the first few lines of the server block code but before any location blocks in there.
SJ77 Posted April 25, 2017 Author Posted April 25, 2017 4 hours ago, Steph40 said: I use this myself: I like this app, it's clean and well done. As far as I can tell though, it only gets me here https://www.mysite.com/forum/index.php?/kyrakane which is a start but I really want www.mysite.com/kyrakane might not be able to get there.
Steph40 Posted April 25, 2017 Posted April 25, 2017 16 minutes ago, superj707 said: like this app, it's clean and well done. As far as I can tell though, it only gets me here https://www.mysite.com/forum/index.php?/kyrakane which is a start but I really want www.mysite.com/kyrakane might not be able to get there. Do you have: location / { try_files $uri $uri/ /index.php?$args; } inside your server block?
SJ77 Posted April 25, 2017 Author Posted April 25, 2017 Just now, Steph40 said: Do you have: location / { try_files $uri $uri/ /index.php?$args; } inside your server block? I don't have it anywhere.
Steph40 Posted April 25, 2017 Posted April 25, 2017 11 hours ago, superj707 said: I don't have it anywhere. Then you need it in your nginx server block for you website or in the default server block. It is that line that makes the rewrite possible on nginx. the default.conf server block should look like this: server { root /usr/share/nginx/www; index index.php index.html index.htm; server_name localhost; location / { try_files $uri $uri/ /index.php?$args; } location /doc/ { alias /usr/share/doc/; autoindex on; allow 127.0.0.1; deny all; } } @superj707 If you had this line before: location / { try_files $uri $uri/ /index.html; } Replace it with: location / { try_files $uri $uri/ /index.html; }
Recommended Posts
Archived
This topic is now archived and is closed to further replies.