admin管理员组文章数量:1130349
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 |1 Answer
Reset to default 0It'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.
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 usedfoo- is that intentional? Or should it all befoo? 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
1 Answer
Reset to default 0It'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.
本文标签: redirectUnable to access folders in same level as wordpress installation
版权声明:本文标题:redirect - Unable to access folders in same level as wordpress installation 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749176799a2327933.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


foo.es, but in other places you've usedfoo- is that intentional? Or should it all befoo? 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