Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [rewrite]

URL Rewriting maps an incoming URL to a modified URL, so that the request is processes as if the original request was made to the modified URL. This is often used to provide more search engine friendly URLs.

2
votes
1answer
16 views

RewriteCond %{HTTP_REFERER} ∈ %{REQUEST_URI}

Is there a way to check using RewriteCond whether the Referer includes the requested URI or... RewriteCond %{HTTP_REFERER} == 'host.com/' + %{REQUEST_URI} ... ? I need to catch whether the surfer ...
0
votes
1answer
7 views

Redirect URL in IIS to different domain and remove portions of the URL

We currently have URLs like: https://tfs.mydomain.com/tfs/MyProjectCollection/Project/_workitems that I need redirected to: https://dev.azure.com/MyOrg/Project/_workitems Using the HTTP Redirect ...
1
vote
1answer
33 views

RewriteMap not working, nothing is rewritten (Apache 2.4)

I have a bit of a unique situation: I need to take a subdomain and make it redirect to a random selection of alternate domains, each of which is on a separate server. Think load balancing, except it's ...
1
vote
2answers
37 views

Nginx Remove Trailing Question Mark From URL

I'm trying to make a rewrite rule in Nginx to remove trialing question mark (?) from urls but i can't get it right. I've done that for trailing slashes like this: #redirect all trailing slash URL's ...
0
votes
1answer
44 views

nginx rewrite url with if and arg

Trying to use a wildcard redirect here but unable to figure out what to set for the wildcard, example: URL: example.com/search?q=broccoli Redirect to: example.com/?s=broccoli broccoli can be ...
0
votes
1answer
19 views

Using nginx rewrite to remove date from URL

Unsure why this isn't working. URL: https://example.com/blog/2009/07/23/example redirect to: https://example.com/example rewrite "^/blog/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)" /$5 permanent;
0
votes
1answer
35 views

How can I rewrite my url to a shorter url in IIS?

I'm trying to rewrite a url from a longer url to shorter url. I want https://contrivedexample.com/favorite-movie/add?id=7&name=pointbreak to rewrite to https://contrivedexample.com?id=7&...
0
votes
0answers
8 views

Apache/NGINX - globally return HTML document if specific request header is set

I want to return a specific HTML document if a request to any path on my site(valid or invalid) contains a specific header(or cookie). Is this possible? Links to relevant documentation are appreciated....
0
votes
0answers
19 views

Rewrite URL and setting accept-language header

I am trying to serve accept-language header-dependent static files, while the URL should always look the same. The important snippet of the apache 2.4.10 config: ... RewriteEngine On RewriteCond %{...
0
votes
1answer
33 views

How can I access an environment variable set by a rewrite rule in an expression?

I am working on a Symfony 3.4 application which has public and private parts. However, I am currently setting up a staging system for this application which should only be accessed by authorized users,...
1
vote
1answer
50 views

Virtual hosts on Apache not applying 301 redirect

I have a Ubuntu 18.04 server on an Amazon EC2 instance running Apache 2, with an SSL certificate installed, which I use exclusively to host virtual hosts for .tld variations of the policymakr.com ...
0
votes
1answer
34 views

nginx evil if alternative?

Looking to see if there is a better way to redirect a query string other than using if in this situation. Example URL: http://foo.com/?p=123 to http://foo.com/new Current using if: location / { ...
1
vote
0answers
37 views

IIS Url Rewrite for Blue/Green deployment

I am following Kevin Reeds tutorial on How to Deploy Anything in IIS with Zero Downtime on a Single Server. Right now I am just trying to get it to work on my local machine, before trying to apply the ...
2
votes
1answer
35 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)...
0
votes
1answer
45 views

Nginx location match if not equal

I have www.example.com/test and i want to write a condition if requested url is not equal to /test do a rewrite or redirect to www.example.com. The closest i can get is a code below but when i want to ...
1
vote
1answer
81 views

Are .htaccess redirects secure/reliable (website maintenance)?

Our website will be going down for around an hour or so for maintenance. All users need to be redirected to a page indicating that the website is receiving an update and/or under maintenance. Will ...
1
vote
1answer
20 views

Access an app's subfolder while the app is itself in a subfolder

I have an app (Symfony) in a folder rapp and I'd like to access via example.com/rapp/. The index.php file is in a rapp/public/ folder. So I'd like to have all my requests to /rapp/ to rewrite to /...
0
votes
0answers
24 views

IIS URL Rewrite username logging

We migrated a SQL SSRS server from one machine to another. In order to make it so that everyone's shortcuts and favorites to specific reports still work, I shut down the old SSRS server and created ...
-1
votes
0answers
7 views

How do I write proper RewriteRule for my case? [duplicate]

I am struggling with the last part, writing proper RewriteRule (maybe I also need RewriteCond?). How do I write proper RewriteRule for my case? I've tried many options without any luck yet. Secondly, ...
0
votes
0answers
23 views

RewriteRule to new server and return 200

Server A is an old server running a web service. It has many clients in the field. Server B is a new server that now receives the requests for the web service along with many others. Server B does not ...
0
votes
1answer
65 views

Nginx: rewrite for subdomain to folder AND files inside it

I have nginx rewrite rule - it redirects all subdomain requests from sub to folder: server { listen 77.77.77.77:80; server_name domaincom *.domaincom; root /home/admin/web/domaincom/public_html/...
0
votes
0answers
21 views

IIS url write to tomcat with windows authentication SSO

are there any ways to pass authentication info from the user's account in windows to Tomcat via IIS Url rewrite? Tomcat will be doing the authentication against the AD with the auth info that came ...
0
votes
1answer
21 views

Combine 2 Nginx rewrite rules with regex

I have a bunch of URL's I am redirecting in Nginx however some have a "-de" on the end of the location which I would like to remove. I am also removing the "bereich/" part of the URL: https://www./...
-1
votes
0answers
12 views

URL Rewrite with Compression Fails with Error 500.52

In my environment I have an IIS server that does the reverse proxy function by rewriting the URL for internal servers using IIS's own Rewrite URL module. There has now been a need to implement ...
1
vote
1answer
41 views

How to debug big redirect chain in nginx. Unexpected redirect

I have a task to make a large site migration now. And i have a large number of redirects in config. But I cannot understand why one redirect causing second redirect in chain. Even if any other ...
0
votes
1answer
55 views

nginx rewrite filename remove part of the name

I can't seem to figure out this nginx url rewrite. This is what I need Url looks like this: /manager/ /manager/dashboard /manager/session /manager/view These map to, in order: /manager/...
0
votes
1answer
13 views

How to handle requests containing given snippets (like phpmyadmin) to another domain using NGINX?

I'd like to redirect all the requests which include any of the words "php" and "admin" (like https://example.com/phpmyadmin) to http://www.cyberpolice.cn I wrote a rewrite line and placed it inside ...
1
vote
1answer
48 views

Nginx Redirect to request_uri

I want to achieve with Nginx return or rewrite option to redirect user request based on request_uri. For example, if user request page mysite.com/test.com then he should be redirected to test.com.It ...
0
votes
0answers
60 views

NGINX rewrite directive breaks the HTTPS redirection

The issue is actually "fairly simple", yet I can't seem to get around it: I'm using AWS ElasticBeanstalk to host an application. For this, I configured the load balancer, an NGINX server, to redirect ...
-1
votes
1answer
78 views

strange character ? added at the end of URL

I have a very very strange thing only on some websites. I have restarted the server where many websites are hosted (for maintenance reasons) and after reboot, some websites only have a ? at the end of ...
1
vote
0answers
22 views

404 on script URL after switching server from Apache to NGINX

I have a woocommerce site that runs a script for accounts that has stopped working after moving from Apache to Nginx. example.com/zynk/index.php/wp_posts?select=ID,meta_value&where=post_type.... ...
0
votes
0answers
15 views

Convert symbol in url

I have a multiplier symbol in url that I would like to convert to x. Like convert any "×" to "x" in url. How to do that via htaccess or nginx rewrite rules? thanks
2
votes
1answer
117 views

Apache .htaccess RewriteRule and ErrorDocument

I have a .htaccess file : RewriteEngine On DirectorySlash Off RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.mp4|\.ttf|\.eot|\.woff)$ RewriteRule ^(.*)$ ?page=$1 [NC,L,QSA] ErrorDocument ...
-1
votes
0answers
33 views

NGINX: How to run 2 Wordress apps under 1 domain?

Hi I have 2 Wordpress apps running under nginx: App 1 at localhost:9990 (/var/www/app_1/public_html) App 2 at localhost:9991 (/var/www/app_2/public_html) Is it possible to make App 2 a child of App ...
0
votes
0answers
25 views

Migrate Apache RewriteRule to haproxy http-request redirect

We have a lot RewriteRules in our Apache config files. Now we have to migrate these rules to haproxy. For Example: RewriteCond %{HTTP_HOST} ^app.mydomain.com* RewriteRule ^/$ https://app.mydomain....
0
votes
1answer
27 views

Nginx caching reverse proxy with URL rewrite

I am serving large static files from a backend storage server with slow spinning disks. This server is hidden behind fast nginx reverse proxy with local cache on SSD. It works great and fast. Now I ...
1
vote
0answers
210 views

NGINX remove all extension types in uri

How would I remove all extension types in the uri through nginx config. I have looked around for solutions and only found solutions for specific file types. For example some configurations would ...
4
votes
1answer
48 views

Trying to get Friendly URL's to work

I have been working on getting friendly URLs to work. On my site I have something like this: http://www.example.com/blog/newpost.php?id=Reasons+to+Use+a+Small+Business+Consultant I would like it ...
1
vote
1answer
26 views

Nginx rewrites taking precedence over redirects?

I have some redirects set up in an include file for our nginx config. I noticed the other day that some redirects aren't working, and they seem to just be the ones that are impacted by rewrite rules. ...
0
votes
1answer
34 views

Rules, URL Rewrite

I'm trying to rewrite two URLs. /Inicio.aspx to /Home and /Usuario/Solicitud.aspx to /Usuario/Solicitudes with the module rewrite of IIS. I made my rules: and put the code in the web.config <...
1
vote
1answer
73 views

IIS URL Rewrite: Match subdomain and redirect to HTTPS

Suppose the website URL is subdomain.company.com I want to redirect the user to https://subdomain.company.com only if The original request is not using https subdomain matches subdomain.comapny.com ...
0
votes
0answers
19 views

Asp.net URL Redirect not working though test is passing in IIS

Blockquote I have asp.net web application and added a entry for URL Redirect. I tested the URL redirect in iis and the test gets passed. Here is the URL redirect rule I am using. <match url="(.*)...
3
votes
1answer
24 views

Regex rewriting with map

I have a url.map containing a rewrite rule ~^/A/shopby/(?<brand>[a-zA-Z]+) ~^/category/by-brand/$brand; so that /A/shopby/a_brand will be redirect to /category/by-brand/a_brand And also a ...
0
votes
2answers
75 views

RewriteRule Irrespective of Trailing Slash in .htaccess

I want to redirect URLs irrespective of trailing slashes. The reason is because my site enforces trailing slashes by default; if an internal link is missing the trailing slash then I have a redirect ...
1
vote
1answer
54 views

Nginx to redirect to specific PHP

I wanted to rewrite the url path to point to certain PHP. Here is the flow: User Login https://admin.abc.com After they logged in, the system will pass url to be redirected https://admin.abc.com/...
2
votes
0answers
60 views

Regex RewriteRule in Apache 2.4 .htaccess

I want the URL: http://api.relaunch.local/rest/v1/akb/ To rewrite to: http://api.relaunch.local/?id=1873&eID=dispatch&controller=akb Where akb is the variable part. I tried endless ...
0
votes
1answer
51 views

Port .htaccess rewrite rule to Nginx

I'm moving from Apache to Nginx and would like to 'port' a rule from my htaccess file: RewriteRule ^api/(.*) slim/index.php [QSA,L] How can I do this in Nginx? An example of a request-url that ...
2
votes
1answer
76 views

NGINX Rewrite subdomain with multiple . as -

On my NGINX server, I am rewriting usernames as a subdomain. However, the server that I inherited, the initial names have a "." to separate out two names. For example: http://foo.com/john.smith is ...
2
votes
3answers
104 views

What's a good way to hide “wordpress” from a WordPress URL?

I have an Apache2 web site with several different resources all installed directly under the DocumentRoot: http://example.com/mycodeigniterapp http://example.com/wordpress http://example.com/...
0
votes
0answers
7 views

Apache Server Htaccess [duplicate]

How to redirect pages without extension to .html ? For example I want the following page : [https://volexlabmultimedia.com/multimedia-service-lucknow][1] To be redirected to: [https://...