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
1answer
16 views

RewriteEngine rules ignored by Apache on SSL

I have a working Apache setup on CentOS 7.6 using the standard Apache 2.4.6-88 package, using HTTP. I am trying to enable HTTPS on the server, and everything works, except for my RewriteEngine rules. ...
0
votes
0answers
12 views

401 error site loads even if I successfully authorize

I am using the following .htaccess which has multiple functions. 1. show authentification box before a user can enter my website 2. add www to URL if URL starts without 3. Always redirect to `index....
3
votes
1answer
202 views

replace domain name in htaccess rule with dynamic hostname

I Have this rule in .htaccess: 1 ## Protect from spam bots ## 2 RewriteEngine On 3 RewriteCond %{REQUEST_METHOD} POST 4 RewriteCond %{REQUEST_URI} .wp-comments-post\.php* 5 RewriteCond %{HTTP_REFERER}...
0
votes
1answer
39 views

Apache destination virtual host certificate when using mod_rewrite or ProxyPass

I am trying to use mod_rewrite or ProxyPass to redirect (PT) the client's request from virtual host A on 443 to different virtual host B on port 4434, also with SSL. Like that: SSLProxyEngine on ...
1
vote
0answers
35 views

Apache SSL reverse proxy to a node server using websockets

Browsing to a root domain like https://sub.example.com and navigating through pages such as https://sub.example.com/page1 works. But only if I start my initial connection at the root. If I refresh ...
2
votes
1answer
38 views

htaccess change document root to /public and prevent /public from being used

I'm hosting a node app and my folder structure is like this: mydomain.com --index.js --package.json --public\test.txt I want to treat public as my document root and not allow anything above it to be ...
3
votes
1answer
57 views

How to exclude RewriteMap if REQUEST_URI is not found

I have an old site wordpress site I am in the process of migrating. There are about 50000 urls that need to be redirected. For this I am using DBM files which seem to be working fine, however during ...
1
vote
1answer
47 views

Apache2 - Only allow .pdf and index access in WebDAV

I've set up a WebDAV with apache2 in order to use it with Zotero. As we only want to upload and download pdfs over this webdav, I want to prevent the upload or download of any other files than pdf ...
0
votes
0answers
34 views

Excluding specific URL to be rewritten in apache reverse

I'm running an Unifi controller behind a reverse proxy (apache). All works fine, except one thing: for guest portal, after authentication, the portal sends a 302 with a non-existing url that is ...
1
vote
1answer
56 views

Mod_rewrite is adding /var/www to the resulting url

I have some problems with the Apache mod_rewrite rules. Whenever I try to go to https://example.com// (see double slashes at the end) it redirects to a 301 page but it's adding the location of the ...
2
votes
1answer
72 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 ...
0
votes
0answers
6 views

htaccess mod rewrite little issue [duplicate]

Helo, i'm trying to get some good results but no luck :( By mod rewrite i want to rewrite url from this: https://mysite.pl/praca/template.php?id=25&ogloszenie=pracownikow-gospodarczych-z-...
3
votes
1answer
35 views

RewriteCond ignored in httpd.conf

Put simply this works in htaccess: RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^([^/]+)/?$ https://example.net?u=$1 [L,NC,R=301] But when ...
0
votes
0answers
38 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
36 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 ...
4
votes
0answers
20 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
36 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
87 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
55 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
20 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 ^/?...
5
votes
1answer
106 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
162 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 ...
4
votes
1answer
66 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
60 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
124 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
674 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
51 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
25 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
67 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
32 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
425 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
190 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
400 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
69 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
203 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
29 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
55 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
83 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
124 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
38 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
376 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
105 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
432 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
399 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
384 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
77 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
195 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
479 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
245 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 ...