$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>redirect - Unable to access folders in same level as wordpress installation|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

redirect - Unable to access folders in same level as wordpress installation

matteradmin6PV0评论

I've got the following structure

www/
  .htaccess
  /website1
  /website2
  /uploads/foo.pdf
  /websiteWP
    .htaccess

.htacces in root (www/.htaccess)

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www.)?foo$

RewriteCond %{REQUEST_URI} !^/website1/
RewriteCond %{REQUEST_URI} !^/website2/
RewriteCond %{REQUEST_URI} !^/uploads/
RewriteCond %{REQUEST_URI} !^/websiteWP/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /websiteWP/$1

RewriteCond %{HTTP_HOST} ^(www.)?foo$
RewriteRule ^(/)?$ websiteWP/index.php [L] 
</IfModule>

.htacces in wordpress installation (www/websiteWP/.htaccess)

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

Inside the Wordpress, clicking the link .pdf will result in an infinite loading page, trying to load content (this reaction is due to the theme, I supose others can have a 404), or sometimes combining half wordpress with half "embeded" remote page.

But going to the pdf from outside the website (pasting in the search box) will work.

Note:

Wordpress URL:

Website URL:

Can't find the failure of the .htaccess.

Already checked all available threads in stackoverflow and wordpress stackexchange.

I've got the following structure

www/
  .htaccess
  /website1
  /website2
  /uploads/foo.pdf
  /websiteWP
    .htaccess

.htacces in root (www/.htaccess)

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www.)?foo$

RewriteCond %{REQUEST_URI} !^/website1/
RewriteCond %{REQUEST_URI} !^/website2/
RewriteCond %{REQUEST_URI} !^/uploads/
RewriteCond %{REQUEST_URI} !^/websiteWP/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /websiteWP/$1

RewriteCond %{HTTP_HOST} ^(www.)?foo$
RewriteRule ^(/)?$ websiteWP/index.php [L] 
</IfModule>

.htacces in wordpress installation (www/websiteWP/.htaccess)

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

Inside the Wordpress, clicking the link https://www.foo/uploads/some-pdf.pdf will result in an infinite loading page, trying to load content (this reaction is due to the theme, I supose others can have a 404), or sometimes combining half wordpress with half "embeded" remote page.

But going to the pdf from outside the website (pasting in the search box) will work.

Note:

Wordpress URL: https://www.foo/websiteWP

Website URL: https://www.foo

Can't find the failure of the .htaccess.

Already checked all available threads in stackoverflow and wordpress stackexchange.

Share Improve this question edited Jun 15, 2020 at 8:21 CommunityBot 1 asked Nov 14, 2018 at 23:33 Qu4k3Qu4k3 135 bronze badges 5
  • In your example link you've used foo.es, but in other places you've used foo - is that intentional? Or should it all be foo? Do you have multiple domains? "But going to the pdf from outside the website will work" - there should be no difference - if the link is the same then the result should be the same, since they both result in the same request. – MrWhite Commented Nov 14, 2018 at 23:48
  • @MrWhite mb doing the dummy data, all is foo – Qu4k3 Commented Nov 14, 2018 at 23:49
  • @MrWhite one is a link inside wordpess clicked through the website, the other one is an external link. But yes, basically the same request. – Qu4k3 Commented Nov 14, 2018 at 23:52
  • ...but with a different result? – MrWhite Commented Nov 15, 2018 at 11:30
  • Yes, I started to think that is more likely to be a theme problem than a missconfirugation. I think there is javascript that make transitions between page and page that provoque the page to not load a page and it tries to load the pdf/external website inside the content of the current site. – Qu4k3 Commented Nov 15, 2018 at 11:35
Add a comment  | 

1 Answer 1

Reset to default 0

It's not clear from the .htaccess files you've posted why you can't access files/folders outside of your WordPress installation (inside the /websiteWP subdirectory). In fact, you shouldn't need to add specific exceptions in order to access physical files, since these directives shouldn't apply to physical files.

However, your .htaccess files are misconfigured...

If the WordPress installation is in /websiteWP directory then the /websiteWP/.htaccess file (in the route of your WordPress installation) is incorrect, as it is routing all requests to /index.php - that's the index.php file in the document root (which I assume is the parent directory), not the WordPress front-controller which should be in the same directory, ie. /websiteWP/index.php).

However, I assume /index.php (in the document root) doesn't exist (otherwise your WordPress site won't work). The .htaccess directives in the root .htaccess file are then rewriting the request back to the /websiteWP/index.php WordPress front-controller! This is extra work and unnecessary.

You should change the /websiteWP/.htaccess file to read:

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

Note I have removed the RewriteBase directive and removed the slash prefix on the RewriteRule susbstitution, changing /index.php (root-relative) to index.php (relative).

Then, the root .htaccess file is not required at all.

Post a comment

comment list (0)

  1. No comments so far