Questions tagged [mod-rewrite]

URL rewriting module for Apache web servers

Filter by
Sorted by
Tagged with
1
vote
0answers
30 views

Apache2 mod_substitute not working in <Location>

I have a working Reverse Proxy that is active only on a specific Location in my site, in this case for example: www.example.com/reverseproxy/site1 I am reverse proxying site1. I want to replace some ...
-1
votes
1answer
59 views

How Do I Use .htaccess to Disguise Query Variables as “Virtual Directories”?

How would I go about having https://example.com/channels/[channel_name]/[video_id] appear in the address bar, but have my PHP script see https://example.com/channels?channel=[channel_name]&v=[...
0
votes
1answer
14 views

Apache rewrite need seperate rules for https?

On a centos8 server I created a file called /etc/httpd/conf.d/rewrite.conf with these contents: RewriteEngine on RewriteRule (.*) https://www.othersite.com [L,R] If I goto http://myserver.com it ...
1
vote
2answers
59 views

RewriteRule (Reverse Proxy) of front page in htaccess not working

The following rule should target my front page (WordPress) to serve a different page instead. RewriteCond %{HTTP_HOST} ^example.com$ RewriteCond %{REQUEST_URI} ^($|\/$|\?|\/\?) RewriteRule ^(.*) ...
1
vote
2answers
89 views

Handling both 301 redirects and internal rewriting in .htaccess

I want to do three things on my website: Redirect users with a 301 to the HTTPS version of the site when they access the HTTP version Redirect users with a 301 to the "no-www" version of the site ...
0
votes
0answers
35 views

Apache rewrite rule to match hex encoded unicode characters in filenames

Long story short - an user zip restored a bunch of files which contain unicode characters, then deleted the zip. The filenames now have the unicodes with some kind of hex encoding, which of course ...
1
vote
1answer
14 views

use proxy or redirect to file if cookie is set and only for a subdirectory

I am currently trying to send the request either through a proxy or to a PHP file based on a cookie. The rule only apply to /api. This is what I have so far. It is part of my VirtualHost Config: ...
1
vote
1answer
34 views

Apache mod_rewrite with Redirect Dropping Authorization Header

I have some Apache mod_rewrite rules set up to redirect Maven deploys from one url/server to another. We're in the process of migrating from Nexus to Artifactory and need these redirects set up so ...
0
votes
0answers
59 views

Can't use parentheses in RewriteCond QUERY_STRING

I need to capture a UID from an old url and redirect it to a new format. example.com/?uid=123 should redirect to example.com/user/123 What should work... RewriteCond %{QUERY_STRING} ^uid=(\d+)$ ...
0
votes
0answers
19 views

Htaccess rewrite a domain to another domain that uses laravel

I have a domain, with some query parameters as a path examp.le/7657 that I then want to map to wwww.myotherdomain/aPath/7657 This domain is served by laravel. So it already rewrites the public ...
0
votes
0answers
100 views

apache redirector to redirect custom url to aws internal dns name

I am using reverse proxy redirecting to internal DNS name of load balancer. As the internal DNS name of Load balancer is too long, I am getting an error ProxyPass worker hostname (internal-xxxxxx-...
0
votes
0answers
22 views

How to count the number PDF downloads using PHP on an NGINX server - conversion of Apache Rewrite Rule

I found excellent rewrite rules and a PHP script that works with Apache to count the number of downloads for certain file types. I need this converted to be NGINX friendly. The Apache rewrite rules ...
0
votes
1answer
33 views

How to get mod_rewrite specific log messages in Windows Server and which file do I need to get?

I have an issue on getting mod_rewrite specific log. I found this on a website and with help from a friend I managed to get this to run in Windows Server Powershell. Below is the command line: Get-...
0
votes
1answer
69 views

How to run command tail -f error_log|fgrep '[rewrite:' in Windows Server

I'm currently performing website redirection from non-www to www+https, but unfortunately, my redirection does not work and I've tried to create rewrite log but it ends up my website down. After ...
0
votes
0answers
12 views

Configurate Apache 2.4 reverse proxy with redirection

Server1 runs apache proxy and webserver tomcat domain: example.com/app1. Server2 runs just webserver tomcat example.com/app2. I'd like to redirect example.com/ to example.com/app1 and app2 server not ...
1
vote
1answer
20 views

apache mod rewrite - initial URL equal rewritten URL

I have rewrite rules and get many logs like: [Thu Mar 26 11:41:00.356526 2020] [rewrite:trace1] [pid 18095] mod_rewrite.c(483): [client xy.xy.220.72:56702] xy.xt.220.72 - - [app.xyz.com/sid#...
1
vote
1answer
45 views

Apache RewriteCond not catching keywords as expected for QUERY_STRING

I'm trying to setup a RewriteRule for Apache 2.4 that allows me to return a 403 code when any keywords are found in the QUERY_STRING. I'm trying to return 403 whenever anyone does some malicious ...
1
vote
1answer
39 views

Does Apache reverse-proxy pipeline requests to origin servers?

When configuring Apache as a reverse proxy (i.e. using ProxyPass or RewriteRule [P]), does it ever pipeline the requests to origin servers, or are they always sent non-pipelined? This is important to ...
1
vote
2answers
84 views

Redirecting old, specific filters to base url of category

Old version of filters and sorting was creating links like (explenation of every part is below - here is example for same category with different views and filters used): https://example.com/category-...
1
vote
1answer
79 views

Apache - mod_rewrite - backreferences understanding

httpd Apache server -> mod_rewrite -> backreferences The following picture is about understanding the reference to parentheses ([Flags] are omitted). If you use parentheses, backlinks are made to ...
0
votes
0answers
26 views

Redirect Rule in my htaccess file

Scanners are picking this line up as threat. I didn't put it there and not sure what it means and google is not coming up with anything. RewriteRule ^(.*)--(conspecies)([0-9]+)-p([0-9]+)\/(.*)$ ?...
1
vote
1answer
35 views

Mod rewrite to get ID from URL

I have the following real URL structure /folder/folder2/file1.php /folder/folder3/file2.php where file1 and file2 could be any PHP file. I also have /folder/folder2/folder4/file1.php /folder/...
1
vote
1answer
32 views

How to redirect from document root to a folder with apache2 mod_rewrite

I have Apache2 on Ubuntu serving several hosts. Some of the hosts have Website and API parts and some folders like uploads which should be kept outside of the document root. I would like to organize ...
0
votes
1answer
296 views

Solved - 500 Internal Server Error Apache, htaccess redirect

So, when i visit a page that is not existing on the main domain www or not i just get the normal 404 error, however when i visit it on a subdomain like dsfds.test.com i get the error 500 and in the ...
1
vote
1answer
39 views

Apache2 wildcard alias

I have the following wildcard vHost: <VirtualHost *:80> ServerAdmin hostmaster@example.de ServerName autodiscover.*.* ServerAlias autoconfig.*.* RewriteEngine On ...
1
vote
2answers
910 views

Apache rewrite any subdomain except one to non-www https

I'm trying to reduce the amount of 301 redirect chaining on my server so I'd like to combine a subdomain to non-www redirect (except where the subdomain is dev) with a HTTP to HTTPS redirect (using %{...
1
vote
1answer
62 views

Setting up two sites on the same IP machine

I have CentOS 8 I installed LAMP, Varnish, etc. I setup hosts /etc/hosts ip site1.com www.site1.com ip site2.com www.site2.com I setup Apache like this: /etc/httpd.conf to include sites-enabled/ ...
1
vote
1answer
57 views

Removing trailing slash from redirected URLs (.jpg/ .htm/ .gif/) with Apache

I have a website that is being redirected from an old host. I don't have the ability to change the redirect of the old host. The issue is that the redirect is appending a trailing slash when it's not ...
0
votes
1answer
48 views

.htaccess Rules to Rewrite Directory as Query Variable

Our site uses the following schema: example.com/channels/channel_name?v=videoId I would like to be able to capture the channel_name directory and rewrite it as a query variable like so: example....
0
votes
0answers
31 views

Apache TRACE method not disabled on port 80

I've tried multiple methods to disable the TRACE method on my Apache webserver but for some reason it's disabled for port 443 but not port 80. I've added the following directive to the top of my ...
2
votes
1answer
126 views

How to “convert” htaccess rules into nginx rule?

I would like to "convert" this rules into an nginx rule. I think the location block is the right place, but my solutions doesn't work. Options -Indexes RewriteEngine On RewriteCond %{DOCUMENT_ROOT}/...
1
vote
1answer
88 views

.HTACCESS is Creating Unnecessary 301 Redirect Chain - How to Remove?

My Stack: LAMP Apache/2.4.41 Background Information: I recently launched a new website for a client. During the re-design process we decided to: Switch to sitewide HTTPS Remove the .php ...
1
vote
1answer
89 views

Recommended htaccess breaks all static content

I am struggling to get my website's CSS, IMG and JS resources to show. My website has this structure: root classes templates public images scripts styles index.php ...
1
vote
1answer
61 views

mod_rewrite suddenly not working, ONLY for incoming POST requests from Foursquare API

I have an endpoint on my website where I receive push notifications from the FourSquare API. The endpoint is: https://www.example.com/auth/foursquare/ On the server itself, the source file is: /...
1
vote
2answers
88 views

Using .htaccess for version control

I am developing a website, and I want to keep the live and some development code on the site. I was thinking of using .htaccess to allow me to develop new code, and then cut over to the new version ...
0
votes
0answers
40 views

Apache redirect with URL rewriting

I read a lot about apache ReverseProxy function but I'm strugling with the configuration. I have a server (called "internal") running Apache 2.4 with proxying enabled (as well as rewrite). In my ...
0
votes
0answers
20 views

Apache RewriteRule, transfer string match into query string parameter

Our website has been redeveloped, and I have been asked to ensure that the previous form of certain URIs are redirected to the new form, so that existing links, bookmarks, etc, don't break. The ...
2
votes
1answer
65 views

Redirect link with query string, but only from specific page

My problem is about that I want to redirect links that contains specific phrase and specific query string after question mark. For example - redirect from: http://example.com/first-category?p=1 to: ...
1
vote
1answer
125 views

Remove leading slash in URLs - Apache

I've been trying to remove the trailing slashes from all URLs. For example, I want the following URLs to redirect: http://my-site-url.com///test -> http://my-site-url.com/test http://my-site-url.com//...
1
vote
2answers
107 views

Using .htaccess to hide the location and extension of .php file

I'm trying to have all requests going to //my.domain/download?id=xx (be it http or https) be processed by /path/to/my/download.php?id=xx. I've tried all sorts of RewriteRule rules to no avail, so ...
0
votes
0answers
31 views

Apache individual DocumentRoot per REMOTE_USER

How can I give authenticated users an individual view of the DocumentRoot? I would like to lock users in their own directory. When alice visits http://example.net/ she only sees /srv/www/alice/ and ...
0
votes
1answer
71 views

400 Bad Request Rewriting HTTP to HTTPS not working

I am running an apache 2.4.25 on a Debian-Server. There is a website reachable via: example.de and www.example.de they should be rewriten via configs and .htaccess to: https://example.de https://...
2
votes
1answer
25 views

Caret within parenthesis in RewriteRule

What does this mean: RewriteRule "(^|/)\." - [F] I know the F flag means to throw a 403 forbidden error. And I know the escaped period means that directories starting with a period are forbidden. ...
0
votes
1answer
42 views

How to fix ProxyPass in URL and subfolder?

I made a proxy pass adding to my localhost instance the path /vocab/arch. Here the configuration I used: <IfModule mod_proxy.c> ProxyPass /vocab/arch http://localhost:...
0
votes
1answer
33 views

Using Apache2 mod_proxy to different server while keeping .htaccess rules somehow working

I am trying to move a part of my website to an external server. I want this part to be accessible through a subdomain, while still being able to apply RewriteRules (doesn't matter whether thats done ...
0
votes
0answers
59 views

Using mod_rewrite to reverse proxy between https domains

I'm on a shared host, so can only do redirects via htaccess, but the plan is to have multiple subdomains (each with a letsencrypt certificate issued via cPanel) to point to a universal set of php ...
1
vote
2answers
140 views

Setup headers in apache2 if URL contains term

Using Apache 2.4.29 and looking to set some headers if the URL contains specific term (api). Here is my attempt I set in the config file RewriteEngine On RewriteCond %{REQUEST_URI} api ENV=SIGN2 ...
2
votes
1answer
444 views

Using Apache rewrite rules in .htaccess to remove .html causing a 500 error

I have written a small website (4 pages, HTML only) and I want to remove the .html extension from the URL by putting some rewrite rules in my .htaccess file, I've Googled around and found several ...
1
vote
2answers
298 views

Rewriting URL encoded hash character with htaccess

I have a single page website that uses the hash (#) to access different pages. The problem is that some PDF viewers break my links encoding the hash character, replacing # with %23, so for example the ...
2
votes
1answer
44 views

apache2 Path rewrite to Get Parameter - Make Slashes work

The following is my current .htaccess file. If I open https://example.com/test and it doesn't end with one of the endings specified in line 2, it will open https://example.com/index.php?url=test ...

1
2 3 4 5
41