How to implement leverage browser caching in nginx? - .htaccess

I have ho access to nginx.conf file (I see it but have no permission to edit it). Trying to add directive for mod_headers in .htaccess - no result. That is interesting, because mod_rewrite works fine through .htaccess

You have to add it to the nginx config, for the location in question to add or change any headers. Unless you can get access to config and reload config, you can't do it yourself.

Related

Nginx .htaccess doesn't work in linux server

hi everyone i have just created website to myself and i editted links using .htaccess (111.111.111.111/list.php | like 111.111.111.111/list ) not include php extension. but when i put files into my linux server, it doesn't work my linux nginx server. when i write 111.111.111.111/list on the url box, it display 404 not found page. it wants to me write 111.111.111.111/list.php
and everything is working on my computer localhost. (i didnt buy domain name i just use only server's ip) please help me
by the way i apologize for my english.
Nginx does not support .htaccess-files because of performance reasons.
https://www.nginx.com/resources/wiki/start/topics/examples/likeapache-htaccess/
You have to do this inside of the nginx configuration file.
To remove the .php maybe this helps:
How to remove both .php and .html extensions from url using NGINX?
If you really need .htaccess, you have to use apache instead of nginx.

Nginx rejects urls like example.com/index.php/some/virtual/path

I just installed NGINX with default configuration and modified config only to accept PHP. PHP is working fine, but my NGINX is not recognizing urls like below:
example.com/index.php/some/virtual/path
How do I get NGINX to recognize such path? I am guessing it isn't recognizing the .htaccess file.
My HTACCESS file looks like this: http://pastebin.com/HQutZ9JL
My current Nginx configuration is: http://pastebin.com/AfFyS8J4
nginx does not support Apache .htaccess files. You will need to rewrite your ruleset in the nginx configuration file. From a quick look at your configuration file, I would start over and enable PHP using FastCGI instead of trying to recreate your specific configuration.

Unable to enable Clean URLs in drupal 7 website after migration

Recently, I migrated my website from local machine to server machine. The website URL is http://www.example.com/myweb
I noticed that only front page is visible and other pages are showing 404 error.
After reading this answer, I got to know that this is happening because of clean URL module. I enabled RewriteBase myweb in .htaccess file but It doesn't work out. Finally I thought of disabling Clean URL temporary as told here. This works well.
Now I wanted to enabled it again. It is showing following error-
Clean URLs cannot be enabled.
Below is the screenshot-
I can see some directory permissions error in status report at admin/reports/status. Are these related to each other?
You need to change your Apache server setting on new server.
Enable 'LoadModule rewrite_module modules/mod_rewrite.so' line in httpd.conf file on your server and restart server
Check if .htaccess works and also check if you have AllowOverrides All in your virtualHost config in Apache.

Configure PhpStorm to use .htaccess

I added .htaccess (for rewriting URLs) in my project's root directory but it's not working. I checked twice, the same file is working fine in Eclipse.
How do I configure PhpStorm to use .htaccess?
Indeed, PHP's built-in web server will never fully support .htaccess features. Note: it is PHP's, it is NOT PHPStorm's built-in server.
But there is a way around.
Most of the time, rewrites are needed only to redirect all the nonstatic file queries to index.php. If you only need this, you can set the server's "router script" in PHPStorm run configuration to index.php.
After that, a modest hack in index.php to serve static files from the drive may speed things up.
Add to the very beginning of index.php:
if (preg_match('/\.(?:php|png|jpg|jpeg|gif|ico|css|js)\??.*$/',
$_SERVER["REQUEST_URI"]))
{
return false; // serve the requested resource as-is.
}
Do you use the same server/configuration when working with PhpStorm and Eclipse?
As it was explained in the comments, it has nothing to do with the IDE, but with the web server (Apache) and its configuration.
You can edit .htaccess with any editor, if this virtualhost/directory configuration has AllowOverride All, ModRewrite is enabled and your rewrite rules are correct, it will work just fine.
You need to ensure that your PHP files are served from the correctly configured web server.

mod_rewrite all robots.txt requests to default file, server-wide

So, I have a development server running OpenSuse with apache. There are loads of projects on this server, some of them have an online/live counterpart.
Each project has a separate subdomain.
How do I rewrite all requests for robots.txt to one "default"-file, server wide?
My goal is to prevent indexing from search-bots.
I believe there is no easier way than to set an Alias in every VirtualHost directive:
Alias /robots.txt /home/path/to/generic/robots.txt
I'm happy to stand corrected by a truly global solution, though.
I was having the same problem and found that I could place the Alias declaration that Pekka suggests in the httpd.conf outside of the VirutalHost directive and it applied to all sites.

Resources