Apache appears to be ignoring my .htaccess file, despite mod_rewrite being enabled and AllowOveride all Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Come Celebrate our 10 Year Anniversary!Which directive could make apache/rewrite redirect products/ to products.phphtaccess rewrite?Difference b/w .htaccess and example.com.confRewrite not working in htaccess (apache2.2.22, windows server 2012)NginX reverse proxy with iRedMail Apache2rewrite rule does not rewrite url as expectedCan't access apache by port 80 from external.htaccess file is not working on Apache 2.4.12 and Windows Server 2008 R2Options +/- interaction with All, which is default in 2.2 but not default in 2.4Default documentroot served from url localhost
When -s is used with third person singular. What's its use in this context?
Antler Helmet: Can it work?
Problem drawing boxes with arrows in tikZ
Single word antonym of "flightless"
What happens to sewage if there is no river near by?
Using et al. for a last / senior author rather than for a first author
Were Kohanim forbidden from serving in King David's army?
Diagram with tikz
What does the "x" in "x86" represent?
Why is there no army of Iron-Mans in the MCU?
How discoverable are IPv6 addresses and AAAA names by potential attackers?
"Seemed to had" is it correct?
Do I really need recursive chmod to restrict access to a folder?
How do I keep my slimes from escaping their pens?
Stars Make Stars
Why did the IBM 650 use bi-quinary?
What do you call a phrase that's not an idiom yet?
ListPlot join points by nearest neighbor rather than order
Is above average number of years spent on PhD considered a red flag in future academia or industry positions?
Did Xerox really develop the first LAN?
Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?
What is the correct way to use the pinch test for dehydration?
Is the address of a local variable a constexpr?
What's the purpose of writing one's academic bio in 3rd person?
Apache appears to be ignoring my .htaccess file, despite mod_rewrite being enabled and AllowOveride all
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Come Celebrate our 10 Year Anniversary!Which directive could make apache/rewrite redirect products/ to products.phphtaccess rewrite?Difference b/w .htaccess and example.com.confRewrite not working in htaccess (apache2.2.22, windows server 2012)NginX reverse proxy with iRedMail Apache2rewrite rule does not rewrite url as expectedCan't access apache by port 80 from external.htaccess file is not working on Apache 2.4.12 and Windows Server 2008 R2Options +/- interaction with All, which is default in 2.2 but not default in 2.4Default documentroot served from url localhost
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
System specifications:
Amazon Linux AMI release 2017.03
Apache/2.4.33 (Amazon)
PHP 5.6.36
DNS is handled by Cloudflare
Here are my VirtualHosts:
<VirtualHost *:80>
DocumentRoot "/var/www/sub.mysite.com/app/public"
ServerName sub.mysite.com
<Directory "/var/www/sub.mysite.com/app/public">
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "/var/www/sub.mysite.com/app/public"
ServerName sub.mysite.com
SSLEngine on
SSLCertificateFile /ssl/mykey.crt
SSLCertificateKeyFile /ssl/mykey.key
<Directory "/var/www/sub.mysite.com/app/public">
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
</Directory>
</VirtualHost>
And the .htaccess that lives within that public directory:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %REQUEST_FILENAME !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %HTTP:Authorization .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%HTTP:Authorization]
</IfModule>
This is a Laravel(PHP) application, meaning that the "public" directory referenced above for the DocumentRoot for my VirtualHost contains an index.php script that is the entrypoint to the application and a .htaccess file which pushes all requests to that script.
I've confirmed that mod_rewrite is enabled both via apachectl -D DUMP_MODULES
and phpinfo. As you can see above AllowOverride All
is set. The permissions for the file also appear to be correct - if I use this script in /public, I get the expected results(.htaccess exists and is readable by the webserver).
However, as far as I can tell the .htaccess is ignored. For example: if I make a request to https://sub.mysite.com/admin/login, Apache appears to look for that path as an explicit file(when it would normally be pushed over to index.php) - excerpt from the global apache error_log:
AH00128: File does not exist: /var/www/sub.mysite.com/app/public/admin/login
If I make an arbitrary PHP script under that public directory and browse to it directly, that script will run as expected.
For what it's worth, I don't think this is a Cloudflare issue - if I hardcode the actual server's IP in my hostfile with the domain, I get the same exact behavior, and I can confirm that the browser is going directly to the server in that scenario and not passing through cloudflare.
So, the Cloudflare DNS A record is working - I'm getting to the server. The VHosts appear to be working, since apache is looking for files in the correct document root. It's just as though apache is ignoring the .htaccess file in that directory, which should take anything in the path of the URL and push it over to the index.php script.
How can I tell if apache is even aware of the .htaccess, let alone parsing it?
Edit: per suggestions in the comments I tried adding some junk to the .htaccess file to see if apache coughed up an error page - no luck. Same behavior. As a control I tried this on a different(working) server and saw the normal Apache error page complaining about misconfiguration. So this tells me that apache either does not see or is purposefully disregarding my .htaccess.
php apache-2.4 .htaccess amazon-linux
add a comment |
System specifications:
Amazon Linux AMI release 2017.03
Apache/2.4.33 (Amazon)
PHP 5.6.36
DNS is handled by Cloudflare
Here are my VirtualHosts:
<VirtualHost *:80>
DocumentRoot "/var/www/sub.mysite.com/app/public"
ServerName sub.mysite.com
<Directory "/var/www/sub.mysite.com/app/public">
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "/var/www/sub.mysite.com/app/public"
ServerName sub.mysite.com
SSLEngine on
SSLCertificateFile /ssl/mykey.crt
SSLCertificateKeyFile /ssl/mykey.key
<Directory "/var/www/sub.mysite.com/app/public">
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
</Directory>
</VirtualHost>
And the .htaccess that lives within that public directory:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %REQUEST_FILENAME !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %HTTP:Authorization .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%HTTP:Authorization]
</IfModule>
This is a Laravel(PHP) application, meaning that the "public" directory referenced above for the DocumentRoot for my VirtualHost contains an index.php script that is the entrypoint to the application and a .htaccess file which pushes all requests to that script.
I've confirmed that mod_rewrite is enabled both via apachectl -D DUMP_MODULES
and phpinfo. As you can see above AllowOverride All
is set. The permissions for the file also appear to be correct - if I use this script in /public, I get the expected results(.htaccess exists and is readable by the webserver).
However, as far as I can tell the .htaccess is ignored. For example: if I make a request to https://sub.mysite.com/admin/login, Apache appears to look for that path as an explicit file(when it would normally be pushed over to index.php) - excerpt from the global apache error_log:
AH00128: File does not exist: /var/www/sub.mysite.com/app/public/admin/login
If I make an arbitrary PHP script under that public directory and browse to it directly, that script will run as expected.
For what it's worth, I don't think this is a Cloudflare issue - if I hardcode the actual server's IP in my hostfile with the domain, I get the same exact behavior, and I can confirm that the browser is going directly to the server in that scenario and not passing through cloudflare.
So, the Cloudflare DNS A record is working - I'm getting to the server. The VHosts appear to be working, since apache is looking for files in the correct document root. It's just as though apache is ignoring the .htaccess file in that directory, which should take anything in the path of the URL and push it over to the index.php script.
How can I tell if apache is even aware of the .htaccess, let alone parsing it?
Edit: per suggestions in the comments I tried adding some junk to the .htaccess file to see if apache coughed up an error page - no luck. Same behavior. As a control I tried this on a different(working) server and saw the normal Apache error page complaining about misconfiguration. So this tells me that apache either does not see or is purposefully disregarding my .htaccess.
php apache-2.4 .htaccess amazon-linux
Add some "nonsense" to the very top of your.htaccess
file (before the<IfModule>
wrapper) - do you get an error? You should also disableMultiViews
in the vHost (ie. use-MultiViews
, not+MultiViews
), not enable it! You are disabling this in.htaccess
- but it is contradictory.
– MrWhite
Apr 10 at 17:24
I've actually tried that too, unfortunately... no dice. Same behavior with or without the junk in .htaccess. So I guess that tells me apache is either not aware of or purposefully ignoring that file. I also removed Multiviews from the vhost per your suggestion as well, though I think that's unrelated.
– jvnk
Apr 10 at 17:42
For kicks I also created a subdirectory under /public with its own .htaccess with junk in it. Same result.
– jvnk
Apr 10 at 17:48
add a comment |
System specifications:
Amazon Linux AMI release 2017.03
Apache/2.4.33 (Amazon)
PHP 5.6.36
DNS is handled by Cloudflare
Here are my VirtualHosts:
<VirtualHost *:80>
DocumentRoot "/var/www/sub.mysite.com/app/public"
ServerName sub.mysite.com
<Directory "/var/www/sub.mysite.com/app/public">
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "/var/www/sub.mysite.com/app/public"
ServerName sub.mysite.com
SSLEngine on
SSLCertificateFile /ssl/mykey.crt
SSLCertificateKeyFile /ssl/mykey.key
<Directory "/var/www/sub.mysite.com/app/public">
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
</Directory>
</VirtualHost>
And the .htaccess that lives within that public directory:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %REQUEST_FILENAME !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %HTTP:Authorization .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%HTTP:Authorization]
</IfModule>
This is a Laravel(PHP) application, meaning that the "public" directory referenced above for the DocumentRoot for my VirtualHost contains an index.php script that is the entrypoint to the application and a .htaccess file which pushes all requests to that script.
I've confirmed that mod_rewrite is enabled both via apachectl -D DUMP_MODULES
and phpinfo. As you can see above AllowOverride All
is set. The permissions for the file also appear to be correct - if I use this script in /public, I get the expected results(.htaccess exists and is readable by the webserver).
However, as far as I can tell the .htaccess is ignored. For example: if I make a request to https://sub.mysite.com/admin/login, Apache appears to look for that path as an explicit file(when it would normally be pushed over to index.php) - excerpt from the global apache error_log:
AH00128: File does not exist: /var/www/sub.mysite.com/app/public/admin/login
If I make an arbitrary PHP script under that public directory and browse to it directly, that script will run as expected.
For what it's worth, I don't think this is a Cloudflare issue - if I hardcode the actual server's IP in my hostfile with the domain, I get the same exact behavior, and I can confirm that the browser is going directly to the server in that scenario and not passing through cloudflare.
So, the Cloudflare DNS A record is working - I'm getting to the server. The VHosts appear to be working, since apache is looking for files in the correct document root. It's just as though apache is ignoring the .htaccess file in that directory, which should take anything in the path of the URL and push it over to the index.php script.
How can I tell if apache is even aware of the .htaccess, let alone parsing it?
Edit: per suggestions in the comments I tried adding some junk to the .htaccess file to see if apache coughed up an error page - no luck. Same behavior. As a control I tried this on a different(working) server and saw the normal Apache error page complaining about misconfiguration. So this tells me that apache either does not see or is purposefully disregarding my .htaccess.
php apache-2.4 .htaccess amazon-linux
System specifications:
Amazon Linux AMI release 2017.03
Apache/2.4.33 (Amazon)
PHP 5.6.36
DNS is handled by Cloudflare
Here are my VirtualHosts:
<VirtualHost *:80>
DocumentRoot "/var/www/sub.mysite.com/app/public"
ServerName sub.mysite.com
<Directory "/var/www/sub.mysite.com/app/public">
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "/var/www/sub.mysite.com/app/public"
ServerName sub.mysite.com
SSLEngine on
SSLCertificateFile /ssl/mykey.crt
SSLCertificateKeyFile /ssl/mykey.key
<Directory "/var/www/sub.mysite.com/app/public">
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
</Directory>
</VirtualHost>
And the .htaccess that lives within that public directory:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %REQUEST_FILENAME !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %REQUEST_FILENAME !-d
RewriteCond %REQUEST_FILENAME !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %HTTP:Authorization .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%HTTP:Authorization]
</IfModule>
This is a Laravel(PHP) application, meaning that the "public" directory referenced above for the DocumentRoot for my VirtualHost contains an index.php script that is the entrypoint to the application and a .htaccess file which pushes all requests to that script.
I've confirmed that mod_rewrite is enabled both via apachectl -D DUMP_MODULES
and phpinfo. As you can see above AllowOverride All
is set. The permissions for the file also appear to be correct - if I use this script in /public, I get the expected results(.htaccess exists and is readable by the webserver).
However, as far as I can tell the .htaccess is ignored. For example: if I make a request to https://sub.mysite.com/admin/login, Apache appears to look for that path as an explicit file(when it would normally be pushed over to index.php) - excerpt from the global apache error_log:
AH00128: File does not exist: /var/www/sub.mysite.com/app/public/admin/login
If I make an arbitrary PHP script under that public directory and browse to it directly, that script will run as expected.
For what it's worth, I don't think this is a Cloudflare issue - if I hardcode the actual server's IP in my hostfile with the domain, I get the same exact behavior, and I can confirm that the browser is going directly to the server in that scenario and not passing through cloudflare.
So, the Cloudflare DNS A record is working - I'm getting to the server. The VHosts appear to be working, since apache is looking for files in the correct document root. It's just as though apache is ignoring the .htaccess file in that directory, which should take anything in the path of the URL and push it over to the index.php script.
How can I tell if apache is even aware of the .htaccess, let alone parsing it?
Edit: per suggestions in the comments I tried adding some junk to the .htaccess file to see if apache coughed up an error page - no luck. Same behavior. As a control I tried this on a different(working) server and saw the normal Apache error page complaining about misconfiguration. So this tells me that apache either does not see or is purposefully disregarding my .htaccess.
php apache-2.4 .htaccess amazon-linux
php apache-2.4 .htaccess amazon-linux
edited Apr 10 at 17:50
jvnk
asked Apr 10 at 17:08
jvnkjvnk
1134
1134
Add some "nonsense" to the very top of your.htaccess
file (before the<IfModule>
wrapper) - do you get an error? You should also disableMultiViews
in the vHost (ie. use-MultiViews
, not+MultiViews
), not enable it! You are disabling this in.htaccess
- but it is contradictory.
– MrWhite
Apr 10 at 17:24
I've actually tried that too, unfortunately... no dice. Same behavior with or without the junk in .htaccess. So I guess that tells me apache is either not aware of or purposefully ignoring that file. I also removed Multiviews from the vhost per your suggestion as well, though I think that's unrelated.
– jvnk
Apr 10 at 17:42
For kicks I also created a subdirectory under /public with its own .htaccess with junk in it. Same result.
– jvnk
Apr 10 at 17:48
add a comment |
Add some "nonsense" to the very top of your.htaccess
file (before the<IfModule>
wrapper) - do you get an error? You should also disableMultiViews
in the vHost (ie. use-MultiViews
, not+MultiViews
), not enable it! You are disabling this in.htaccess
- but it is contradictory.
– MrWhite
Apr 10 at 17:24
I've actually tried that too, unfortunately... no dice. Same behavior with or without the junk in .htaccess. So I guess that tells me apache is either not aware of or purposefully ignoring that file. I also removed Multiviews from the vhost per your suggestion as well, though I think that's unrelated.
– jvnk
Apr 10 at 17:42
For kicks I also created a subdirectory under /public with its own .htaccess with junk in it. Same result.
– jvnk
Apr 10 at 17:48
Add some "nonsense" to the very top of your
.htaccess
file (before the <IfModule>
wrapper) - do you get an error? You should also disable MultiViews
in the vHost (ie. use -MultiViews
, not +MultiViews
), not enable it! You are disabling this in .htaccess
- but it is contradictory.– MrWhite
Apr 10 at 17:24
Add some "nonsense" to the very top of your
.htaccess
file (before the <IfModule>
wrapper) - do you get an error? You should also disable MultiViews
in the vHost (ie. use -MultiViews
, not +MultiViews
), not enable it! You are disabling this in .htaccess
- but it is contradictory.– MrWhite
Apr 10 at 17:24
I've actually tried that too, unfortunately... no dice. Same behavior with or without the junk in .htaccess. So I guess that tells me apache is either not aware of or purposefully ignoring that file. I also removed Multiviews from the vhost per your suggestion as well, though I think that's unrelated.
– jvnk
Apr 10 at 17:42
I've actually tried that too, unfortunately... no dice. Same behavior with or without the junk in .htaccess. So I guess that tells me apache is either not aware of or purposefully ignoring that file. I also removed Multiviews from the vhost per your suggestion as well, though I think that's unrelated.
– jvnk
Apr 10 at 17:42
For kicks I also created a subdirectory under /public with its own .htaccess with junk in it. Same result.
– jvnk
Apr 10 at 17:48
For kicks I also created a subdirectory under /public with its own .htaccess with junk in it. Same result.
– jvnk
Apr 10 at 17:48
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "2"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f962468%2fapache-appears-to-be-ignoring-my-htaccess-file-despite-mod-rewrite-being-enabl%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f962468%2fapache-appears-to-be-ignoring-my-htaccess-file-despite-mod-rewrite-being-enabl%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Add some "nonsense" to the very top of your
.htaccess
file (before the<IfModule>
wrapper) - do you get an error? You should also disableMultiViews
in the vHost (ie. use-MultiViews
, not+MultiViews
), not enable it! You are disabling this in.htaccess
- but it is contradictory.– MrWhite
Apr 10 at 17:24
I've actually tried that too, unfortunately... no dice. Same behavior with or without the junk in .htaccess. So I guess that tells me apache is either not aware of or purposefully ignoring that file. I also removed Multiviews from the vhost per your suggestion as well, though I think that's unrelated.
– jvnk
Apr 10 at 17:42
For kicks I also created a subdirectory under /public with its own .htaccess with junk in it. Same result.
– jvnk
Apr 10 at 17:48