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 [mod-rewrite]

URL rewriting module for Apache web servers

0
votes
0answers
32 views

Converting conditional (if statement) mod_rewrite ruleset to nginx config

I have this Apache conditional mod_rewrite ruleset that (on request) subdomain.html.example.com dynamically opens a html page located in /home/user/source/html/subdomain/public_html/ otherdomain.html....
0
votes
1answer
31 views

How do I tell the client the new filename with mod_rewrite?

I'm trying to convert requests like /download.php?name=one into /downloads/one.zip instead. The following sends the correct file, but the client saves it as download.zip instead of one.zip ...
2
votes
0answers
14 views

A little confusion about DBM files and how they work

I have apache 2.4 and am using RewriteMap DBM files. ie: <IfModule mod_rewrite.c> RewriteEngine On RewriteMap examplemap "dbm:/etc/httpd/conf/rewrite.dbm" RewriteCond ${examplemap:$...
0
votes
0answers
20 views

Apache forward proxy rewrite destination

I'm trying to setup Apache 2.4 as a forward SSL proxy so it can function as my main entrance point to Docker containers. The virtual host works when I send it an http address, but not for https. The ...
1
vote
1answer
52 views

apache 2.4 - double encode already encoded query string in URL

I need help regarding a requirement. We have Apache 2.4.6 installed I have a URL which has an encoded query string: https://example.com/home?testStr%3Dhello%26id%3Drad I am trying to find out how ...
0
votes
1answer
39 views

Apache redirect Absolue url to relative url

So I want to load a web-app from a subfolder. Current configuration looks like this <VirtualHost *:80> ServerName YOUR IP ADDRESS/DOMAIN ServerAdmin webmaster@localhost ...
1
vote
1answer
18 views

Apache Rewrite not working

I have a very strange thing happening in my apache2 setup. I just want to redirect HTTP to HTTPS. I have tried all possible ways, like this: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^/?...
4
votes
1answer
76 views

Mixing DBM Rewrite and Redirect how to stop Rewrite if url is not in list

The scenario: I need to be able to both redirect certain urls and rewrite other URL's Right now after much tinkering I am able to get almost everything to work If I hit the example.com works ...
1
vote
1answer
101 views

Why are Apache Rewrite Conditions not working?

I tried to perform a redirect writing in .htaccess file: RewriteEngine on RewriteRule article-1 www.another-site.com/article-1 [R=301,L,NC] and it works correctly. Anyway, when I add a rewrite ...
3
votes
1answer
30 views

RewriteMap dbm .dir .pag

I have been working with RewriteMap dbm, I was able to the text version working however cannot figure out how or why I am getting the error described below. The Virtual host: <VirtualHost *:80>...
0
votes
2answers
38 views

Apache2 URL Rewrite with Reverse Proxy

I've been trying to accomplish a goal of using Apache as a reverse proxy to translate HTTP to HTTPS as well as using mod_rewrite to inject a query string. The reverse proxy works if tested without ...
1
vote
2answers
62 views

ModSecurity SecRule based on original browser url, not internal rewrite (index.php, app.php, etc.)

I'm working on a Symfony 2 site, and am trying to create a ModSecurity rule to match a particular browser URL. IE example.com/results Symfony 2 internally rewrites all requests to app.php using ...
8
votes
1answer
639 views

HSTS and double redirect

I manage a little website in a shared hosting LAMP environment: this basically means the only thing I can edit is an htaccess file. I wanted to add HSTS support (and I did it), but, when I tested my ...
1
vote
1answer
34 views

htaccess issues with non existent files in non existent directories [duplicate]

I am using the following .htaccess file, which works well, however, I want to also forward any attempts to access non-existent files in the root directory and in any subdirectory (whether the ...
0
votes
0answers
23 views

Apache Load Balancer — How to know which Route was chosen on 1st pass

I am using Apache 2.4.x to Load Balance (mod_proxy) for AB testing to slowly introduce a new server while we retire an old server & service. Everything I need is working, except for a small issue ...
0
votes
1answer
63 views

Using mod_rewrite to redirect single pages

The first requirement was to redirect traffic from http://www.old-domain.org to https://example.press -- but only do so for the root of the domain; any specific page should be available on the old ...
1
vote
1answer
30 views

Best way to add authentication layer to static file requests?

I am trying to figure out the best way to add an authentication check to requests for static assets on my server. I am running Apache2.4 and PHP/Laravel, which runs by serving static content ...
0
votes
2answers
185 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/...
1
vote
1answer
189 views

redirect non-www to www AND http to https ONLY for the root path

I'm having a hard time figuring out how to properly configure a mod_rewrite rule for the following conditions: redirect non-www to www AND http to https ONLY for the root path: / ie. example....
2
votes
1answer
165 views

Redirect to %-encoded URL parameter using mod_rewrite in .htaccess

There's a couple of things I'm trying to understand in relation to a RewriteRule. The working rule on a URL strips a query back to a redirect, eg. the URL: https://www.example.com/application?user=...
2
votes
1answer
65 views

Apache Redirect based on directory match & Add another letter to the destination URL

So here’s what I’m trying to accomplish. I have this link, I want to 301 redirect: Origin URL: https://www.example.com/folder1/page.aspx?fh_location=%2f%2fpackages%2fnl_BE%2fpr_earlybookable%3E%7b0%...
1
vote
1answer
129 views

Apache Redirect to /index.php - How to handle direct requests for /index.php

I'm not 100% sure if this should be on server fault or stack overflow, though I'm leaning towards server fault. Most PHP frameworks utilize Apache redirects to funnel all request to /index.php and ...
0
votes
2answers
26 views

apache2 reverse proxy, rewrite issue

I keep telling myself this should be simple. Background: I had a site set up (https://example.com) using Let's Encrypt for the SSL setup. Works great. I added a new server to the internal network with ...
0
votes
1answer
16 views

apache2 reverse proxy configuration

I have one application that listens on TCP 127.0.0.1:81. I want to accomplish the following redirection: www.example.com/?requestid=123456 --> http://127.0.0.1:81/?requestid=123456 www.example....
0
votes
0answers
50 views

How to reverse proxy a suburl to a port

I have Jupyter running on port 8888. I used the following to reverse proxy that port to jupyter.myserver.com. <VirtualHost *:80> ServerAdmin admin@myserver.com ServerName ...
0
votes
2answers
82 views

Apache mod_rewrite redirects me to https://www.(literally) for some reason

I configured an Apache server on my Ubuntu 18.04 computer with HTTPS support. I have a SSL Certificate for *.example.com so my solution for have HTTPS on example.com was to redirect it to www and ...
1
vote
2answers
122 views

Dirty redirects in .htaccess

text/x-generic .htaccess ( UTF-8 Unicode text ) RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # BEGIN WordPress <IfModule mod_rewrite.c> ...
2
votes
0answers
37 views

HTTPS redirect, exclude script parameters from URL [closed]

My goals: 1. http://example.com/page/index.php -> https://example.com/page/ 2. http://example.com/page/ -> https://example.com/page/ 3. http://www.example.com/page/ -> https://example.com/...
1
vote
1answer
250 views

Apache: Redirect all .html AND .php requests to folder + WordPress

After a relaunch I have a bunch of dead backlinks pointing at URLs with .php or .html file-extensions. It would be nice to redirect them in bulk using .htaccess and the mod_rewrite module. The ...
0
votes
1answer
86 views

Finding the source of a 301 redirect (through .htaccess or wp_redirect()

One of my interns applied a 301 redirect on one of the site's pages (domain.com/nice-page) to another page (domain.com/pretty-page) and I'd like to remove that redirect. The problem is that he is ...
2
votes
1answer
193 views

.htaccess rewriterule if/else

I have the following .htaccess code: RewriteEngine on <if "%{HTTP_HOST} =~ /^helpdesk\./"> RewriteRule ^/?$ /index.php?pages=helpdesk&file=index [NC,L,QSA] </if> <if "%{...
1
vote
1answer
210 views

Apache error on SuSE : Invalid command RewriteEngine, perhaps misspelled

Webserver: Apache 2.4 on SuSE 12, multiple vhosts 4 vhosts (2 ssl, 2 http) have RewriteEngine on and some simple rewrite rules. mod_rewrite is available and active (checked with a2enmod -l) Problem:...
1
vote
2answers
199 views

301 Redirect everything to another domain, except for a subdomain

I am trying to redirect: domain.com and www.domain.com to https://www.newdomain.com with a 301 redirect, except for subdomain.domain.com. I tried different methods but these are not working. I am ...
1
vote
1answer
57 views

Apache2 proxy fastcgi conditional rewrite with proxy pass match and cookie

I currently have two projects: /home/piotrek/Vhosts/sf.local/web/app_dev.php /home/piotrek/Vhosts/sf2.local/web/app_dev.php Both have same repo but are set to two different branches. I have vhost ...
1
vote
1answer
119 views

mod_rewrite - RewriteCond if %{HTTP_HOST} is NOT any ServerName/ServerAlias

I want to know if it's possible to make a Rewrite Condition for if the %{HTTP_HOST} is NOT the ServerName or any of the listed ServerAlias. My goal is to redirect any requests made to a domain that ...
1
vote
1answer
355 views

Rewrite rule not fully working in .htaccess [duplicate]

Ok, this is in conjunction with my other post: Rewrite not working in .htaccess file However, this is not a repost of the same question. This time I am only focusing on the first part of my .htaccess ...
0
votes
1answer
179 views

Apache Httpd 2.4 Rewrite Rule to return 301 redirect, but returns 302

I have two different examples of where Apache Httpd 2.4 on Centos7 is configured to perform redirects with the R=301 flag, but they are actually returning 302 redirects. One is an extremely simple ...
1
vote
1answer
132 views

Rewrite not working in .htaccess file

Update 6/26/18: I appreciate that this may be a duplicate of Redirect, Change URLs or Redirect HTTP to HTTPS in Apache - Everything You Ever Wanted to Know About Mod_Rewrite Rules but Were Afraid to ...
0
votes
1answer
48 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 ...
0
votes
0answers
111 views

Apex / Apache + reverse proxy + mod_rewrite with HTTPS

I am running Apex on an Oracle Linux Server, and my vhosts file looks like this: <VirtualHost *:80> ServerName www.example.com ServerAlias example.com Redirect permanent / https://example.com/ ...
0
votes
0answers
27 views

Apache rewrite rule not working for blocking spamdexing referrer http://site.ru [duplicate]

I have the following rewrite rule in my .htaccess file. <IfModule mod_rewrite.c> RewriteEngine On # START Upgrade unsecured connections RewriteCond %{HTTP_HOST} my-site-com-dot-com\.com [NC] ...
1
vote
1answer
24 views

How to silence useless Apache mod_rewrite log messages?

I have some mod_rewrite rules to redirect junk requests made by bots to a static 404 page, like: RewriteRule ^(.*)\.asp(.*)$ https://%{SERVER_NAME}/errors/404.html [L,R=301,NC] I have a few dozen of ...
1
vote
1answer
87 views

Apache redirect - remove all queries

I am trying to remove all queries in URL: https://api.myserver.com/image.png?arg=0 should become https://api.myserver.com/image.png I used this: RewriteCond %{QUERY_STRING} ^arg=0$ ...
1
vote
2answers
268 views

Apache rewrite causes infinite recursion if subdirectory is requested

I have a rewrite rule that works most of the time. However, if I request a page with a subdirectory that doesn't exist, and the subdirectory matches an existing file, it causes infinite recursion. ...
0
votes
2answers
95 views

Redirect to another server using apache virtual-Host reverse-proxy

I have a server running on Ubuntu. I can access to that server via reverse proxy with Apache. Now comes the stuff I want to do. I want to redirect to another server (not the same machine) when ...
0
votes
0answers
24 views

Rewriting in Apache a complex/incorrect URL format to a proxy server

We have an Apache front-end with a Tomcat backend. We proxy all requests that match a specific file string format to it. However, it seems that Tomcat is having problems handling an old URL format ...
0
votes
1answer
174 views

mod_rewrite — .htaccess redirect to new url with /path and query string intact

Looking for help in writing an .htaccess file to redirect to a new address with the url/query string intact -- User url input: http://www.example.com/path?query-string=something    -...
1
vote
1answer
49 views

Performing two replacement types in .htaccess

Consider an .htaccess file which must convert all underscores to dashes, and replace a potential .html suffix with a slash in the filename. Example URL from client: http://foo.com/a_b/c_d.html ...
0
votes
1answer
37 views

Apache2 Cannot make work simple mod_rewrite rule

I would like to configure my apache2.4.7 to redirect requests internally like this: /app/download/somefile => /app/download.php/somefile or sth comparable. After various attempts which all don't ...
0
votes
1answer
143 views

Apache: Open same .php file with any URN (abc.com/<blabla>) but keep the URL

I basically found a part of my solution here: Apache rewrite rule and keep the url unchanged? but I want to do more. I want to open a "template.php" site which comes up on any URN entered. So if I ...