All Questions
Tagged with mod-rewrite nginx
383 questions
0
votes
0
answers
39
views
Do I need to use REGEX/URL rewriting for my BeEF / Nginx reverse proxy config?
I am running BeEF on an Nginx Virtual Server, behind Nginx which is acting as a reverse proxy. Furthermore, the webpage which the BeEF hook will sit on is also on a separate virtual server, also ...
0
votes
0
answers
33
views
Mirroring pkgs.tailscale.com with nginx fails, mirroring tailscale.com works
I am trying to mirror/reverse-proxy the package server pkgs.tailscale.com because that server is blocked at some locations.
For some reason I can easily mirror the regular tailscale.com website with ...
0
votes
0
answers
25
views
Laravel RewriteRule on htaccess with "at sign" @ for profile names on URL
I am trying to create a rewrite rule on a Laravel project route; the most straightforward approach should be like this:
RewriteEngine On RewriteRule ^@([^/]+)$ /someurl/$1
However, trying this on a ...
0
votes
0
answers
23
views
Error Too many redirects when changed from Apache to Nginx
I have migrated my website from Apache to Nginx. I had issue after migration.
Current .htaccess configuration:
RewriteBase /
RewriteRule ^home$ index.php
RewriteRule ^file/? do.php?id= [QSA]
...
0
votes
0
answers
31
views
Using mod_rewrite to simplify and shorten URL parameter [duplicate]
I'm trying to get the following URL: https://example.com/database?serial_number=XYZ
Turned into https://example.com/database/XYZ
So far everything I have tried either didn't work, created redirect ...
1
vote
1
answer
50
views
Recreating Apache .htaccess in Nginx
I've been tasked to create some previously working Apache rewrites to work on Nginx. There's a whole bunch of rules that we were instructed to create by the SEO consultants that are working fine on ...
1
vote
1
answer
79
views
.htaccess redirect based on folder
I need help with .htaccess Rewrite rules.
I have a API which can be accessed over http://api.my.domain/products/all which is working fine and is returning result.
I would like to redirect users coming ...
1
vote
1
answer
767
views
Rewrite URL's to Subdomain in NGINX
I have several url's that I would like to rewrite in NGINX
for example:
From: app.example.com/calendar
To: calendar.example.com
Or
From: app.example.com/meetings
To: meetings.example.com
I would ...
2
votes
1
answer
533
views
Convert Apache rewrite rules (front-controller) to Nginx
I need a small hand fixing rewrite rules for Nginx.
Folder structure is like this:
dev.example.com/public_html << contain the site
<IfModule mod_rewrite.c>
Options -Multiviews
...
0
votes
1
answer
246
views
Conversion of Nginx to Apache Rewrite Rule
I'm having to move nginx sites over to apache and I'm having an issue w/ mod rewrite rules. These are my nginx rewrite rules and I'm not... quite... nailing it as I've tried various iterations on my ....
0
votes
2
answers
773
views
How to configure .htaccess for a Laravel API app which is hosted on a subdomain?
I have a domain mydomain.com and a nginx space to host my website. The URL address mydomain.com is already in use and I don't want to buy another domain, so I created a subdomain myapp.mydomain.com. ...
0
votes
1
answer
134
views
NGINX: redirect request_uri that contains http
I have rewritten all external links sent to standard output on the fly as an internal link in PHP from https://externalsite.com to https://myexamplesite.com/https://externalsite.com, yet I want Nginx ...
1
vote
1
answer
849
views
WordPress in Docker container throws error 500 with Post title permalinks
I am trying to host WordPress blog under a subdirectory URL like:
https://example.com/blog
Because I have another application running on https://example.com/
Everything is under a Nginx reverse proxy
...
0
votes
0
answers
170
views
Stop redirect to root when accessing location block for a folder outside server root in nginx
I am running a web client for a mapping service and the app resides in a folder called prod. I have copied prod to var/www/html/.
This is my sites-enabled conf for a Laravel app I have running already....
0
votes
0
answers
378
views
Redirect dynamic urls with Nginx
In my website i have links like this:
https://example.com/blog/some-text
So due to the structure of my paths, the code has to read them like this:
https://example.com/blog/_entry.php?title=some-...
0
votes
0
answers
163
views
Regular expression for nginx redirect
What is the correct expression for denoting this -
beginning/ulp-12GiwQpe/doesnotmatterwhatishere
I want to change this to
beginning/doesnotmatterwhatishere
for NgInx, where 12GiwQpe is any random ...
0
votes
0
answers
92
views
Nginx rewrite to ignore letters added after URL
I am currently writing the nginx rewrite to ingore any letters in url .
For example my application url is:
http://example.com/downloads
Rewrite to ignore anything else added after actual url and ...
0
votes
0
answers
187
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 ...
0
votes
0
answers
71
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$...
3
votes
0
answers
115
views
Nginx directives not running concurrently
Some links on the site are sent with Ajax, and the ".php" extension is not available at the end of these links.
E.g; https://panel.example.com/app/controller/ajax/collect
At the same time, ...
0
votes
1
answer
89
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
577
views
URL with Rewrite in Nginx
I want the URLs to look clean and nice with rewrite. I was able to do this while using Apache, but I installed Nginx on the server. So I don't use .htaccess.
While using Apache, I was using it like ...
0
votes
2
answers
73
views
How to redirect NGINX
I'm trying to redirect from
https://support.example.com.br/
for
https://support.example.com.br/?SSO=1
how do i do this through nginx?
my code is like this:
server {
listen 8080;
index index....
1
vote
1
answer
2k
views
Rewrite one specific argument with nginx rewrite
I want to rewrite an argument given via URL on my nginx server from "my_arg" to "my-arg". The problem is that I can't know how many arguments there will be in advance nor the ...
1
vote
0
answers
383
views
Rewriting dynamic urls in nginx config
I'm working on a PHP app, and I have moved it from apache to nginx server. I have a php page that dynamically creating xml files for sitemap . This works perfectly in apache server but when i moved to ...
0
votes
0
answers
50
views
How can I strip unwanted parameters from url by NGINX
How can I strip unwanted parameters from url by Nginx, for example:
http://example.com/?good=1&bad1=something&bad2=something&bad2=something&good=2
redirect to:
http://example.com/?good=...
1
vote
1
answer
44
views
How do I set an nginx rewrite rule for my project that contains both client and server code?
I have a file structure that looks like this
demo
|+ build
| |+ images
| | |- logo.png
| |+ static
| |+ css
| | |- style.css
| |+ js
| |- index.html
|+ controllers
|+ api
|- users.php
...
0
votes
0
answers
175
views
How to put URL/$directory into rewrite url parameter in NGINX?
What I need is to pass as a parameter what comes after the slash.
https://example.com/berlin
to
https://example.com/index.php?c=berlin
So far for testing I had done it like this:
location / berlin {
...
0
votes
1
answer
191
views
Nginx - how to read the custom response header?
I am using nginx and trying to read a custom header from an internal page. $http_name variable doesn't work with my nginx/1.14.2 server.
if ($http_crawler != '1') {...}
Do you have any idea how to do ...
2
votes
2
answers
688
views
nginx redirects all files with or without extensions except a few
How to match all files with or without extension, except those with the extension txt, pdf, jpeg.
On my Nginx configuration this downloads all the files without any restriction.
location ~ .+(?<!\....
0
votes
0
answers
331
views
How to find request param in nginx reverse proxy
Regarding nginx reverse proxy I am struggling to get the parameters values from the request URL in NGINX conf.d
My URL is https://abcd.cloudfront.net/app/dashboards#/view/aa501030-e93e-11eb-bdcf-...
1
vote
1
answer
545
views
Cannot remove .html from url
I have a static site and I'm trying to remove the .html from the url, so when I visit the site www.example.com/home.html I should get: www.example.com/home.
This is my project structure:
project
...
0
votes
1
answer
91
views
convert htaccess rule to nginx server block
I've the following code in .htaccess file for the folder /rest-api inside main root folder.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*...
1
vote
2
answers
113
views
How to convert htaccess to nginx
I have problems to convert a htaccess file to nginx. Maybe someone can help me.
I need the following code converted:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{...
1
vote
1
answer
2k
views
Rewrite URL to index.php using nginx server
I need a help to configure my website on nginx server. Earlier i was using apache so there i was using htaccess to redirect on index.php. But i just got to know that nginx don't support htaccess. I am ...
0
votes
1
answer
172
views
How to convert a simple index.php redirection from apache to nginx format?
From an old project, I got this .htaccess file, which currently handle the apache rewrite rules:
<IfModule mod_rewrite.c>
RewriteEngine On
# Folders / files to exclude from rewrite ...
0
votes
1
answer
895
views
Bitrix24 On-Premise site failing to load the pages with error message. This site can’t be reached. connection refused
I am failing to access the Bitrix24 On-Premise site. When I enter http://intranet/ the site is redirecting to http://intranet:8890 and then gives an error "This site can’t be reached" ...
1
vote
0
answers
50
views
Nginx - try_files regex
I need to migrate a website from Apache to Nginx.
In this project, there is a .htaccess with theses rules :
RewriteCond %{REQUEST_URI} /(.+)/media/([0-9]+)\.(.+)\.(.+)\.(.+)
RewriteRule .* - [E=...
1
vote
1
answer
76
views
migrate htaccess rewrite to nginx
I have the followinf rewrite rule on htaccess:
RewriteEngine on
RewriteCond %{THE_REQUEST} /([^?]+?)(?:\.php)?\?lang=([^\s&]+) [NC]
RewriteRule ^ /%2/%1? [R=301,L,NE]
The rule redirects "...
1
vote
3
answers
2k
views
Wordpress Routing not working in Digital Ocean using nginx
I am struggling with this from quite sometime now and thought to ask the community.
I have recently started working on digital ocean and nginx. I was using apache earlier.
I have a simple wordpress ...
0
votes
0
answers
804
views
how to disable basic authentication when using kerberos on nginx?
Foreword
In the main body of the question, the problem is described incorrectly. The correct explanation is described in the UPDATE block. Old text saved for history.
My project consists of two ...
0
votes
1
answer
87
views
Nginx re-directions from "www" to "non www" and from "http" to "https"?
I have my app hosted in the base URL: https://myapp.com/
Now I want to add re-directions from "www" to "non www" / "http" to "https", where:
https://myapp.com/
https://www.myapp.com/
http://myapp....
3
votes
1
answer
882
views
Call to PHP page served by nginx without using the file extension
I'm sure this is a really simple answer, but I just can't seem to crack it. I'm also quite new to nginx, but quite knowledgeable with apache2. I'm running nginx on Ubuntu and trying to fulfill these ...
0
votes
1
answer
39
views
.htaccess dash in argument
I have the following htaccess rule:
RewriteRule ^listen/([^/]*)-([^/]*)/$ listen.php?pl=$1&id=$2
Sometimes the second argument (id) has a dash in it and I get 404 Not found, e.g:
mysite.com/...
0
votes
0
answers
39
views
Translate Nginx rewrite rule to Apache
Help with changing code in Nginx, I would like to pass it to .htaccess, is that possible?
location ~ ^/api/(?:tickets|tasks|auth).*$ {
try_files $uri $uri/ /api/http.php?$query_string;
}
2
votes
2
answers
3k
views
Nginx rewrite rule path to query string
Examples:
example.com/asd -> example.com/portal.php?id=asd
example.com -> example.com/portal.php
example.com/asd?document=new -> example.com/portal.php?id=asd&document=new
So far works only:
...
1
vote
1
answer
796
views
How to rewrite randomly generated nginx path by taking the first segment?
I have a prestashop instance that generates a random URL for admin access. The only rule is that the path starts with "admin".
The following rule works just fine, but its hardcoded by hand:
location ...
0
votes
1
answer
38
views
Redirection subdomain
I was trying now for hours to get it working but without a solution.
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{HTTP_HOST} ^forum\....
1
vote
1
answer
1k
views
Nginx URL rewrite for api/rest to rest/v1
Current API end points are like
domain.com/api/rest/[actual_module_routing_path, eg. cms/page/home]
In the new system this has to be something like
domain.com/rest/V1/$1
It has to work regardless ...
1
vote
1
answer
282
views
Limit amount of parameters in query string
I just want to limit the amount of parameters that nginx/apache allows to pass. For example: if someone tries to access a link like test.php?arg1=value&arg2=value&arg3=value give them a 404 ...