I am using nginx for the first time in my life.
I came to know that nginx does not follow htaccess.
Rewrite rule the way we applied in htaccess should apply in nginx conf file. I don't know how.
I opened nginx conf file. I used this converter to convert my htaccess to nginx config file. I attached htaccess and equivalent config file.
I even don't know whether rewrite mod is enabled or not? Or I will say I don't know exact way to find it out.
htaccess code
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
php_value session.cookie_domain .abc.in
Nginx conf
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
#rewrite on;
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server
{
listen 80;
server_name abc.in;
# nginx configuration
location /
{
if (!-e $request_filename)
{
rewrite ^(.*)$ /index.php;
}
}
}
}
I was wrong. This is a path mistake. I was changing file at different location.
I never found clear documentation on internet for this.
When I was doing some stuff on nginx server found that nginx does have sites-enabled
directory which holds a file named default
which holds server level configuration.
I changed index.html
to index.php
and everything works!!!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.