Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Nginx rewrite help
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Nginx rewrite help

aldothetrollaldothetroll Member
edited July 2014 in Help

I want http://exampleurl.com/location/examplefile.php to become http://exampleurl.com/location/examplefile

This works but it rewrites everything including CSS / JS urls etc. so the site doesn't load properly.

rewrite ^/location/(.*)$ /location/$1.php last;

Can someone help me please?

Comments

  • try_files $uri $uri/ $uri.php;

    Thanked by 2Boxode aldothetroll
  • @Rallias said:
    try_files $uri $uri/ $uri.php;

    Does not work. Updated the OP hopefully it gives more insight on what I'm looking for.

  • CloudconeCloudcone Member, Patron Provider

    rewrite ^/location/(.*)$ /location/$1.php last;

    The problem is the browser thinks the document root is /location/examplefile/ which is not.

    So as a fix when you are loading JS or CSS in the script tag use /path/to/js instead or path/to/js

    Note: the / in the front :)

    Thanked by 1aldothetroll
  • MaTMaT Member

    Or try html base tag

    Thanked by 1aldothetroll
  • @Rallias said:
    try_files $uri $uri/ $uri.php;

    After more tweaking this finally works. Thank you all for your help.

Sign In or Register to comment.