How would I convert the following Apache rule
RewriteRule ^watch/([A-Za-z0-9-]+)/?$ watch.php?v=$1 [NC]
into the appropriate format for an NGINX configuration file?
Further edit:
server {
listen 80;
listen [::]:80;
server_name domain.tld www.domain.tld;
root /var/www/ROOT;
index index.php index.html index.htm;
return 302 https://www.domain.tld$request_uri;
location / {
#
# HIDE PHP EXTENSION
#
try_files $uri $uri/ @extensionless-php;
}
location /watch.php {
rewrite ^/watch/([A-Za-z0-9-]+)/?$ /watch.php?v=$1;
}
#
# HIDE PHP EXTENSION
#
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
#
# BLOCK REFERRER URLS
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 401 /error_pages/401.php;
error_page 403 /error_pages/403.php;
error_page 404 /error_pages/404.php;
error_page 405 /error_pages/405.php;
error_page 408 /error_pages/408.php;
location ^~ /error/ {
internal;
root /error_pages/;
}
nginxserver configuration block.return 302which should not be there. And thelocation /watch.phpshould belocation /watch. And you should probably stick alastmodifier on the end of therewrite.serverblocks see this