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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Questions tagged [mod-rewrite]

URL rewriting module for Apache web servers

2
votes
1answer
33 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
52 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
61 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
23 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
15 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
34 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
80 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
106 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
34 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
167 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
51 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
62 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
51 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
94 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
32 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
53 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
90 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
100 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
120 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
40 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
52 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
26 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
21 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
80 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
193 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
93 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
23 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
80 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
45 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
35 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
123 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 ...
3
votes
0answers
79 views

Apache correctly redirects all URLs of webpage to HTTPS except for base URL http://dev.example.com

Setup is on an ecommerce platform. eCommerce platform uses a uri.php? URI management system to handle serving page contents. Only able to see the htaccess file for the site for the time being [limited ...
1
vote
1answer
53 views

How do I internally rewrite all requests to subdirectory? [duplicate]

I'm using Laravel 5.6, and I can only upload/edit files to/in the root of the website (/public_html). I cannot change the website root to /public_html/public. Is it possible to rewrite all requests (e....
3
votes
2answers
106 views

Apache2 not rewriting as expected

I have a VPS on Digital ocean, hosting two websites, each with multiple domains. Website 1: https://jeremiahrose.com/ Alternative domains: jeremiahro.se, jeremiahrose.band, www.jeremiahrose.com, www....
1
vote
2answers
92 views

apache2 mod_rewrite redirect without http body [duplicate]

I am currently using Apache mod_rewrite to redirect to HTTPS, but I would like to remove the body from the response. How it is currently: Example: How I would like it to be My redirect ...
-1
votes
1answer
439 views

Apache Rewrite redirect all pages except for specific [duplicate]

I am retiring a site and would like to display a message when anyone tries to access any page on the site EXCEPT for a couple of pages. Some pages have certain pageid parameters. So basically ...
3
votes
1answer
296 views

Apache - Need to rewrite /contact/ to /contact.php

Using .htaccess from my previous question, I edited it to add a rewrite rule for rewriting /contact/ to /contact.php and /xyz/contact/ to /contact.php?lang=xyz. While the second one works, the first ...
3
votes
1answer
206 views

.htaccess mod_rewrite too many redirects

Just to make things clear, this is NOT a duplicate question like this one as core of question is different. What I'm trying to do is redirect users who try to access a site using a language code (...
0
votes
2answers
210 views

Apache2 mod_rewrite won't work

conf file: <VirtualHost *:27010> DocumentRoot /var/www/test/public_html <Directory /vaw/www/test/public_html> AllowOverride ALL </Directory> </...
1
vote
1answer
158 views

Apache reverse proxy double trailing slash

I have a reverse proxy setup in my virtual host. However, when I visit the site: https://example.com instead of https://example.com/ in the browser address bar, I get https://example.com//. Why do I ...
0
votes
2answers
151 views

Apache rewrite rule prefixing DocumentRoot

I've got the following config for a VirtualHost: <VirtualHost *:80> DocumentRoot /srv/emptywebroot <Directory /srv/emptywebroot> Require all denied </Directory> ...
0
votes
1answer
62 views

htaccess - Can this be done? (Nested IfModules)

I'm trying to redirect to a URL if a test for a module passes. Something like this (Which doesn't seem to work for me.) Perhaps this just isn't possible. Anyone? <IfModule mod_rewrite.c> &...
1
vote
0answers
95 views

Apache mod_rewrite and mod_proxy conflict

I am using Apache, mod_proxy and mod_rewrite I wish for the following: https://www.example.com.*?secure=true to return a 403 https://www.example.com.* to proxy to https://www.example.org I have ...
1
vote
1answer
133 views

Removing .php from example.com/.php

For removing just .php from my urls, I currently have the following # Remove trailing slashes RewriteRule ^(.*)\/$ $1 [NC,L,R=301] # Remove trailing .php extensions RewriteCond %{THE_REQUEST} (\S*?)...
0
votes
1answer
58 views

Domain redirect

I'm trying to add a rewrite rule for an old domain test.fr. I have placed my rule in our virtualhost in the httpd.conf file with rewrite engine on, I'm not sure why .htaccess wasn't used. rewrite ...
1
vote
1answer
223 views

extract query string param value in RewriteRule

I'm writing an apache 2.4 Rewrite rule in order to remove a query string param and create a cookie from its value. eg: http://example.com/?param1=value1&my_param=my_value&param2=value2 to ...
1
vote
1answer
218 views

GeoIP: Redirect all but specific countries

I am using Apache's GeoIP module and a MaxMind database to determine the country of a visitor based on their IP address and redirecting them to a country sub-folder as shown below: RewriteCond %{ENV:...
0
votes
1answer
20 views

What is the format for combining several Parameters in RewriteCond?

I want to use the current [OR] but also add: [L,R=301,NC] for a permanent redirect. So is that [OR, L,R=301,NC]?
0
votes
2answers
30 views

Apache RewriteRule error adding Locales to new URL

I am in the process of redirecting a URL and I wanted to use the 'RewriteRule' directive when in the process of doing so. I currently have a rule as follows: RewriteRule ^/application/web/...
0
votes
0answers
22 views

nginx apache sessions by GET method

We have and old windows webserver that doesn't manage cookies so we are using a workaround (since 7 years ago) which consist on using GET sessionID in visible URLs: www.website.com/INDEX.pro?...