I have got WordPress installed on my root example.com/ Website.
Also I have another Web application that on example.com/my-app/ which has got ugly links like example.com/my-app/file.php?arg=value to access.
How can I make my-app SEO friendly URI structure working as example below?:
example.com/my-app/file.php?arg=value
to
example.com/my-app/value/
Currently, if I access to example.com/my-app/value/ it redirects me to my WordPress post which contains some characters of the /value/. Why? Is there anyway to get this working?
My Nginx directives for domain are listed below:
location / {
try_files $uri $uri/ /index.php?$args;
fastcgi_read_timeout 300;
}
location ~ .php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
Any ideas? Should I use Ajax navigation, with switch cases? What about HTML5 pushState() API? Any working examples?
Thanks for help!
Both WordPress and
my-app
work within a common document root which makes things simple.The last element of the
try_files
directive is the default action for (for example) SEO friendly URLs.You need a different default handler for URIs which begin with
/my-app
, which is achieved using alocation /my-app
block, for example:In the above case,
arg
is set to the value/my-app/value
. If you really must extract the last part of the URI, add a named location with a rewrite, for example:Note that the
fastcgi_read_timeout 300;
(in your question) needs to be placed in thelocation ~ .php$
block, or in one of the outer blocks, in order to be effective.See this for details of the
nginx
directives used above.