• Resolved cerealrunner

    (@cerealrunner)


    I have a directory on my server that has the same name as one of my pages. The link to the page, rather than opening the page itself, takes one to the directory and lists all the files in that directory. Is there a way to force WordPress to open the page instead?

    • This topic was modified 5 years, 3 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic
Viewing 3 replies - 1 through 3 (of 3 total)
  • Disable Directorylisting https://www.thesitewizard.com/apache/prevent-directory-listing-htaccess.shtml
    Enable Directoryindex https://www.htaccess-guide.com/directoryindex-uses/
    Currently you cannot use files, folders that actually exists outside the context of WordPress, you have to delete the existing folder or file and WordPress when it is not a regular file or it is not a directory thinks it is a slug of the path.

    The reason this happens is you have that directory defined and the webserver (probably Apache) gets the first crack at the URL and it looks first for a directory since that’s how the webserver works.

    BTW: The reason it shows a file list is there is no index.html file there in that directory so Apache creates a file list and sends that to the browser.

    Your WordPress never sees the URL so it isn’t the problem.

    The best fix is to get rid of or rename the directory or else not create a page with the exact same name as a directory.

    If you need that directory itself then you probably should place it in the content subdirectory under uploads. If that’s not a good solution then consider renaming the page in some manner.

    Thread Starter cerealrunner

    (@cerealrunner)

    Thank you @autotutorial and @jnashhawkins !

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Link opens a directory on my server’ is closed to new replies.