• My question, is, how does WP on a localhost process a URL that is simply a link to a CSS file, for example.

    I have 2 local projects that have the same structure.

    If I type the following into the browser, the CSS file is displayed.
    localhost/target/wp-content/themes/oceanwp-child/assets/css/demo.css

    However, when I type the same path for the other project, as follows,
    localhost/chfootball/wp-content/themes/oceanwp-child/assets/css/demo.css

    I get “This site can’t be reached”. The underlying reason being that http has been replaced by https in a 301 redirect.

    I originally thought that WP would not get involved in a request like this and that it would be handled by Apache, but the fact I’m getting different results would imply WP is getting involved in responding to the request.

    So, my question is, can anybody tell me what processes are going on within WP to produce the response for this request? I am trying to locate what is causing the 301 redirect.

    thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • WP is not involved in a request for an existing file. That is part of the commands in the .htaccess file.
    So your two setups are not identical.

    Thread Starter apg1912

    (@apg1912)

    Thanks for the reply, but I’ve checked the .htaccess files for both projects and they are identical, except for the fact one references ‘chfootball’ and the other references ‘target’. The commands in each are the same though.

    • This reply was modified 5 years, 1 month ago by apg1912.
    Thread Starter apg1912

    (@apg1912)

    .htaccess

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /chfootball/
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /chfootball/index.php [L]
    </IfModule>

    What I meant was that you are assuming that WordPress is doing something in your test case. Since it is a request for an existing file, WordPress is not involved, so you have to look at your setup, not at WordPress.

    Thread Starter apg1912

    (@apg1912)

    That is the problem. The set up outside of WordPress is identical other than the names of the folders. As far as I can see, .htaccess is the only file that can be used for customisation, and it is not doing anything differently in these cases. It all points to Apache for me but I have no idea where this 301 redirect is originating.

    Bottom line is that there MUST be a difference, certainly the apache server can tell the difference.
    What about directory and file owners and permissions ?
    Thanks for posting the .htaccess file, see the line:
    “RewriteCond %{REQUEST_FILENAME} !-f”
    It translate as “if the file exists, then do not rewrite”, this test is failing !
    Have you done any SSL configuration ?
    What is in the apache “sites-enabled” configuration files ?

    Thread Starter apg1912

    (@apg1912)

    Thanks for the suggestions. There is no SSL configuration on this PC. I decided to follow up on your directory file owner suggestion.

    I moved the demo.css file into every folder leading back to the route.

    localhost/chfootball/demo.css
    localhost/chfootball/wp-content/demo.css
    localhost/chfootball/wp-content/themes/demo.css
    localhost/chfootball/wp-content/themes/oceanwp-child/demo.css
    localhost/chfootball/wp-content/themes/oceanwp-child/assets/demo.css

    All the above display the file okay. However, as soon as I issue the following:

    localhost/chfootball/wp-content/themes/oceanwp-child/assets/css/demo.css

    I get the Site Not Found due to 301 redirect to https.

    Thing is, I can see no difference in the permissions of the css directory compared to the ones above it. I must be missing something and so I will continue to follow up this line of thought.

    All the permissions are inherited all the way down from C:/ so there must be something else at play.

    • This reply was modified 5 years, 1 month ago by apg1912.
    • This reply was modified 5 years, 1 month ago by apg1912.
    Thread Starter apg1912

    (@apg1912)

    I thought I’d add the following as it may be relevant.

    I created a new folder called ‘demo’ under ‘assets’ and copied in the contents of the ‘css’ folder.

    Typing in the following url worked!
    localhost/chfootball/wp-content/themes/oceanwp-child/assets/demo/demo.css

    So, I deleted the ‘css’ folder, and renamed ‘demo’ to ‘css’. And guess what? It failed again! Is there something special about the directory name ‘css’?

    • This reply was modified 5 years, 1 month ago by apg1912.
    Thread Starter apg1912

    (@apg1912)

    By getting the website to reference a folder called ‘styles’ instead of ‘css’ containing the same files, the site works again. I had the same problem with a folder called ‘images’, and so I created a new folder at the same level called ‘imgs’, copied in the contents of ‘images’, and that then worked as well.

    I have looked at the folder properties, permissions, etc for a long time, and so see no differences between them and so I am at a loss to explain any of this other than some folder corruption that has somehow occurred.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How is URL processed by WP?’ is closed to new replies.