All Questions
Tagged with mod-rewrite nginx
79 questions
-1
votes
1
answer
190
views
Test a website without changing DNS settings
I need to test a website before changing DNS records.
There are tools such as Skipdns.link and in the past hostcx. I need this but without the limitation of skipdns.link.
For example all URLs of ...
1
vote
1
answer
159
views
RewriteCond rules from apache to nginx
RewriteCond %{TIME_SEC} >40
RewriteCond %{TIME_SEC} <56
RewriteRule ^(.*)the-product(.*)$ https://www.%{HTTP_HOST}/%{REQUEST_URI} [R=301,L]
I want to convert it to nginx but there is no ...
0
votes
0
answers
380
views
Convert multiple Apache/.htaccess files to Nginx config
main .htaccess
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress ...
0
votes
0
answers
211
views
Apache2 behind NGINX: MOD_REWRITE only works without HTTPS
For days I can't get my head around the following problem:
We have an application (Faveo) which has two requirements for going through the setup wizard:
HTTPS & MOD_REWRITE.
Faveo is running on ...
1
vote
0
answers
194
views
When the ".php" at the end of PHP Files is removed, it becomes 302 redirect
I remove the .php file attachment in the application, but this time the application's action pages do not work. Because I removed the .php suffix at the end of the files.
For example, I want to send ...
4
votes
1
answer
1k
views
use "rewrite" and "try_files" together [Nginx]
I removed the ".php" suffix at the end of the PHP files on the Nginx server with the following code, but this time I cannot send some data to the server.
try_files $uri/ $uri.html $uri.php$...
0
votes
0
answers
100
views
"rewrite" structure for subdomain on Nginx
I want to do a custom rewrite for the subdomain on ISPconfig. When I add the code below for this, the subdomain is redirected to the main domain.
Sample #1:
server {
...
if ($http_host = "...
2
votes
1
answer
478
views
Exclude google doc embed iframe from nginx rewrite rule?
I hope that someone can help me here as I have very limited knowledge about server related stuff.
I have a WordPress site where I want to limit the /wp-content/uploads/ directory access to logged in ...
2
votes
1
answer
311
views
NGINX Redirect to Cached File in Subfolder
I have a program that creates optimized versions of pictures that are uploaded to the /images/ folder on the web server. It traverses subfolders and in each one, creates a .optimized folder that holds ...
-1
votes
1
answer
96
views
Modify Apache rewrite rule for Nginx
How to rewrite this Apache rewrite rule for Nginx?
RewriteCond %{REQUEST_URI} ^/api
RewriteRule (.*) index.php [L]
I tried this but it doesn't work, I'm getting HTTP 404 in /var/log/nginx/access....
0
votes
2
answers
829
views
RewriteRule conflict and trailing slash
We are migrating a website to our cPanel infrastructure. The customer hosted the website on his own infrastructure using Nginx. He sent to us his Nginx configuration files and we converted them to ...
0
votes
3
answers
3k
views
How can I return 404 for specified existing file in apache and nginx?
I need to return 404 error for some specified files like 'config.php' . How can I do it with '.htaccess' in Apache? And in nginx without htaccess? Thanks.
0
votes
0
answers
560
views
How to count the number PDF downloads using PHP on an NGINX server - conversion of Apache Rewrite Rule
I found excellent rewrite rules and a PHP script that works with Apache to count the number of downloads for certain file types. I need this converted to be NGINX friendly. The Apache rewrite rules ...
2
votes
1
answer
526
views
How to "convert" htaccess rules into nginx rule?
I would like to "convert" this rules into an nginx rule. I think the location block is the right place, but my solutions doesn't work.
Options -Indexes
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/...
0
votes
2
answers
3k
views
Nginx: Rewrite sub-directory to different directory
Currently I have a directory that is down a bit in the codebase, I need to move it to a url that I use on the old server that uses Apache.
In Apache I have:
RewriteRule ^ait/(.*) system/ait/$1 [L,...
0
votes
1
answer
118
views
Convert this .htaccess to nginx [duplicate]
I am having some problems trying to translate this to nginx, today I can't make my brain to work well and solve this!
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ $1 ...
2
votes
1
answer
1k
views
Convert nginx rules to .htacees
I am trying to convert my nginx blocks to apache(.htaccess) file but not able to achive it. Can you please help me with this
location = /index.php {
if ($arg_a = get) {
return 301 /$arg_a/$...
1
vote
1
answer
4k
views
Nginx friendly URL rewrite rules
I have recently migrated from Apache to Nginx and the performance is impeccable.
The site is a download server (mainly) with a custom PHP script.
Some example URLs are like:
https://sub.example.com
...
2
votes
1
answer
562
views
How to remove mass trailing slashes(Nginx)
I need to remove mass trailing slashes, now I have
rewrite ^/(.*)/$ /$1 permanent;
So www.example.com/ becomes www.example.com.
It's good, but when I go to www.example.com/// (any amount of slashes)...
3
votes
2
answers
25k
views
nginx rewrite url without changing browser address
I want to change the url of a request but the browser address should not change.
To achieve this I have tried the below configuration:
location /my-website {
proxy_pass http://tomcat/...
0
votes
1
answer
102
views
port RewriteRule from apache to nginx
we have a large php application running on apache now which I would like to migrate to nginx. I’ve got everything to work correctly except for a RewriteRule in a .htaccess file.
The web app allows ...
2
votes
1
answer
1k
views
Redirect 301 issue Apache behind Nginx
My non-www example.com has been redirected to www.example.com/index.php.
Note: I'm redirecting using .htaccess and not with nginx virtual host file.
RewriteCond %{HTTP_HOST} ^example.com [NC]
...
0
votes
1
answer
116
views
converting htaccess url rewriting rules into nginx
How can i convert my htaccess rules here
RewriteRule ^/?([^/]+)/([^/]+)/?$ page-1.php?a=$1&b=$2 [L,QSA]
RewriteRule ^/?([^/]+)/([^/]+)/([^/]+)/?$ page-2.php?a=$1&b=$2&c=$3 [L,QSA]
into ...
1
vote
2
answers
7k
views
Pass URL component/path to PHP with Nginx
I recently switch from Apache to Nginx. I'm brand new to Nginx, so please be kind. One of my apps uses the first URL component as a query string unless the path/file exists - in which case Apache ...
0
votes
1
answer
4k
views
nginx reverse proxy apache url silent rewrite and https rewrite
I have a nginx + apache configuration running. I am VERY VERY new to nginx and I am having quite a time trying to learn it.
First I want to do a basic rewrite. As per my understanding, when nginx is ...
-2
votes
1
answer
1k
views
How to convert this Apache rewrite rule to Nginx
I've been struggling to convert my past Apache rewrite rule to Nginx (also not sure if I'm placing it in the right place so would appreciate if you can tell me where to place it).
Basically, this was ...
1
vote
1
answer
2k
views
nginx How to rewrite all urls except few having specified extensions?
i am trying to convert rewrite rules from .htaccess files to nginx config. as a part of moving site to NGINX webserver.
here are rewrite rules from .htaccess file
Options +FollowSymLinks
...
1
vote
1
answer
2k
views
deny all folder except some php files [closed]
I have a script for set some limitation on download host.
this script give me some file(index.php|dl.php|config.php) that I have to put them on my download host.
The script also has these htaccess ...
1
vote
0
answers
132
views
nginx mod_redirect if first part of uri is not a file
I'm migrating from Apache to Nginx server and trying to figure out how to replace my .htaccess with nginx config.
In my rewrite I want to enable pretty links and need the server to check if the first ...
3
votes
1
answer
2k
views
Rewrite leads to infinite 301 redirect loop on existing directories
I went through questions/solutions found here, tried numerous approaches (including the [L] directive) but nothing really did the trick.
Situation Overview
Debian running Apache 2.2 proxying through ...
2
votes
1
answer
2k
views
Converting nginx to Apache rewrites
I'm trying to set up Symfony from an existing site that's on nginx. My local machine is Apache and this is the redirect scheme on nginx. How do I write this using RewriteRules?
location / {
...
1
vote
1
answer
2k
views
mod_rewrite issue Apache behind Nginx
I have nginx proxying to apache as a backend in order for nginx to handle static assets. Unfortunately when I attempt to visit a "pretty url" it just displays the index page.
nginx config
server {
...
7
votes
1
answer
15k
views
url rewrite, nginx throw 404 errors, nothing in error logs
below rewrite works fine:
rewrite ^/city/restaurants$ /city/listings/restaurants permanent;
but this doesnt work
rewrite ^/city/restaurants$ /city/listings/restaurants last;
rewrite ^/city/...
2
votes
0
answers
3k
views
NGINX - rewrite_log does not work log rewrites anywhere
I was attempting to learn rewrites, by making something like this:
^/blog/install/(.*)$ --> /blog/install/index.php?_p=$1
However these rewrites simply kept failing, and it was difficult to ...
1
vote
1
answer
165
views
Switching from apache to nginx - mod_rewrite issue
I just switched my server over from apache2 to nginx and now I am having some issues with my .htaccess rewrites.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -...
1
vote
1
answer
4k
views
Nginx url rewrite file not found
I have converted my .htaccess to work with Nginx but i have many 404 errors or wrong display for folder and subfolder rewriting.
This Nginx config works for folder and subfolder but for /view/ its ...
1
vote
0
answers
45
views
Converting .Htaccess Rewrite Rule to Nginx
I have the following apache rewrite rule which I am trying to convert to work with nginx.
RewriteRule ^(.*)\/(.*)-(\d{4})(?:-(.*))?$ album.php?artist=$1&album=$2&releaseyear=$3&extra=$4
...
0
votes
1
answer
129
views
How to share a Single Domain SSL certificate across 2 ip addresses
I have a wordpress website example.com. I have a single domain SSL certificate that can be used across multiple servers.
When a user visits example.com, or any subfolder expect forum , they access ...
1
vote
0
answers
208
views
Special nginx hotlink protection conversion from Apache .htaccess rule
I have the following anti-leeching rewrite rule in Apache, which i'd like to have in nginx. I see cookie or referrer rule examples. But none combining both, so I am not sure how to go about this.
<...
1
vote
1
answer
6k
views
Joomla URL Rewriting works automatically in Nginx
This is driving me nuts and I dont understand how this works automatically. I have nginx as my web server and I have installed Joomla that has URL Rewriting which removes the index.php from the URL. ...
4
votes
3
answers
4k
views
nginx [emerg] unknown "0" variable
I've been trying for two days to convert an .htaccess to nginx rewrite the original file looked like this:
# Turn on URL rewriting
RewriteEngine On
RewriteBase //
# Protect hidden files from being ...
-1
votes
1
answer
2k
views
Exclude location from nginx if directive
Currently I use this for redirecting everybody to the SSL page:
if ($scheme != "https") {
rewrite ^ https://$server_name$request_uri? permanent;
}
does someone know how to exclude a specific ...
-2
votes
1
answer
655
views
Nginx rewrite rule not working
Can someone help me convert this rule?
I have over 50 rules, but I can not make this rule work:
#APACHE
RewriteRule ^([^/]*)/([^/]*)\.html$ /?cmm=$1&page=$2 [L]
2
votes
0
answers
2k
views
nginx rewrite for php restful api apache htaccess
I have an apache htaccess file used with Restful API tutorial
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$...
0
votes
1
answer
207
views
redirect string to different url in nginx
I want to redirect a string to different URL in nginx.
This what my vhost looks like and is working fine.
server {
listen 80;
server_name secure.example.com;
root /opt/tomcat/webapps/test/;
...
-1
votes
1
answer
3k
views
Reverse proxy 502 bad gateway
I have setup a subdomain to proxy my plesk panel, but when saving pages I am getting 502 Bad Gateway error instead of a completion message. I am running CentOS 6.
Here is my vhost.conf configuration ...
0
votes
1
answer
1k
views
convert lighttpd to nginx rewrite rules
I'm trying hard to make my code work on nginx. This configuration works with lighttpd but I want migrate it to nginx.
Rewrite rules on lighttd :
url.rewrite-once = (
"^/(ui)/(.*)$" => "/gi.php/$...
0
votes
1
answer
4k
views
nginx url rewrite rule
I'm doing a migration from a WordPress blog to a Jekyll Blog using NGINX as my HTTP server and I don't want to break the Internet by leaving some URL's not working as expected. I got to a point where ...
-1
votes
1
answer
100
views
Nginx redirect sub.domain.com/users/page/somename to somename.sub.domain.com
I've been trying to redirect http://sub.domain.com/users/page/somename to http://somename.sub.domain.com etc.
Any pointers?
0
votes
2
answers
5k
views
How to change NGINX server name
In the Apache web server we can change the server signature (Apache Name) using mod_rewrite.
For example - http://www.howtoforge.com/changing-apache-server-name-to-whatever-you-want-with-mod_security-...