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.
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