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.
Related
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.
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.
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.
Is it possible to execute .htaccess file on Tomcat?
We are trying to get phphgadmin to work and so far we can only load the first screen that display some folder links. When we click on them we get a 404 error and we suspect it might be URL rewriting.
You can't run phpmyadmin on tomcat, because tomcat can't interpret php (nor it can interpret .htaccess)
What you need is Apache HTTP server, and if you need to also run Java, use mod_jk or mod_proxy_ajp (comparison) - a way to let apache serve what tomcat "produces".
I'm running nginx for static files(images, scripts) on 81 port and apache with php on 80.
Is it possible to redirect with .htaccess all iamges, styles, scripts requests to the same url but 81 instaed of 80 port?
I'm not very familiar with mod_rewrite
something like
if mysite.com/path/file.xxx has extension jpg or png or css
then redirect to mysite.com:81/path/file.xxx
thanks!
Normally you would do it the other away around: have Nginx proxy anything that's not a static file to a backend Apache. Having Apache look at all the incoming requests would defeat the purpose, since you use Nginx to avoid the inefficiencies of Apache when handling numerous requests. http://kbeezie.com/view/apache-with-nginx/ is a reasonable guide to the setup.