Questions tagged [mod-rewrite]

mod_rewrite is an Apache module that allows for server-side manipulation of requested URLs.

Filter by
Sorted by
Tagged with
0 votes
0 answers
7 views

Apache2 rewrite HTTP redirects [duplicate]

I'm trying to use calibre web as a Docker container and have it exposed via Apache2 acting as a reverse proxy. I already have a Nextcloud installation under example.com/nextcloud, and I would like to ...
  • 1
1 vote
1 answer
51 views

mod_rewrite rules on subdirectory not woring due to parent rules

My application lives in one directory and is served from a public folder, and I have an API endpoint in a sub-directory of public, both of which are redirected to their own respective index.php files. ...
  • 537
0 votes
0 answers
13 views

Apache rewrite url in wsgi site

This is my apache site with wsgi application. What I need is add string "Auth_Basic" between last slashes in the request. Request can be different anytime. Example: http://127.0.0.1/asd/lala/...
0 votes
0 answers
48 views

Apache 2.4.52 HTTPS Rewrite no longer works on Ubuntu 22.04

I have been forcing HTTPS upgrade through mod_rewrite for years on Ubuntu 18.04 LTS servers. I recently upgraded a few of these servers to Ubuntu 22.04.1 LTS to ensure the latest security and Apache ...
0 votes
0 answers
10 views

How can i make apache limit requests to a certain url within a certain time frame?

I'm trying to use mod_evasive and mod_rewrite to accomplish this. With the configurations below apache just blocks all access to those URI's regardless of how many times a visitor accesses them within ...
0 votes
0 answers
30 views

Apache RewriteCond/RewriteRule with variables causes infinite redirects

I'm trying to use variables in the RewriteCond and RewriteRule like so: SetEnv DOMAIN "example.com" SetEnv SUBDOMAINS "www|assets" #more config stuff, unrelated #I separated the ...
  • 101
0 votes
0 answers
28 views

Serve mixed case files case-insensitive on Linux Apache without mod_speling?

On my media subdomain (nice separation of concerns, also for rulesets) I have files which are in Mixed-Case-intentionally (for maximum semantics, also for downloads) which I want to serve case-...
  • 143
0 votes
0 answers
21 views

Apache RewriteRule losing one slash of the https://

On my apache server, I need to pass full URLs as parameters to a php function. However, when I use something like: RewriteRule ^(.*)$ ../image.php?url=$1 $1 ends up losing one of the slashes of the ...
  • 205
0 votes
1 answer
40 views

Redirect rules for multiple enviroments

I have written a set of rules for 3 different environments on the same server. In a nutshell I would redirect the users to the Dev, Stage and Prod single sites. Also enforce https and www for the ...
  • 1
1 vote
0 answers
73 views

Apache 2.4 "client denied by server configuration" caused by Require expr - even though the request succeeds

Our apache error log is littered with messages saying client denied by server configuration, even though the htaccess configuration is working as intended. Here is the relevant bit of the htaccess: ...
  • 111
1 vote
1 answer
22 views

Apache ToLower on all Wordpress pages (not PDF/CSS/JS)

I'm having issues performing a 301 redirection of URLs that contain capitals to lowercase, excluding static files (PDF/CSS/JS/JPEG/JPG/PNG/WEBP...etc). For example: https://www.example.com/Page/ would ...
0 votes
1 answer
15 views

mod rewrite - do consecutive rules use original, or rewritten url?

If you have two rewrite rules, and the first gets applied, does the second use the rewritten result of the first, or the original URL? I cant find this info in the documentation.
  • 531
0 votes
1 answer
19 views

mod_proxy + mod_reqrite results in errors 502 or 502

I have working httpd config (reverse proxy) that forwards requests to proxy: Listen 443 https <VirtualHost *:443> ServerName public-dns.example.org ServerAlias internal-hostname....
  • 111
1 vote
1 answer
54 views

Redirect all URLs ending in ".-detail" to remove the dot

I have a rather odd situation where our old URLs are ending in .-detail and need changing to just -detail. For example: example.com/product.-detail needs changing to example.com/product-detail In ...
0 votes
0 answers
16 views

Redirecting all 404s to a custom page using Nginx $mod_rewrites

How to redirect all 404s and any random characters after my domain all to the main domain? I'm using $mod_rewrites = [ code because .htaccess and other things are not working. For Example : From this ...
  • 1
1 vote
1 answer
110 views

Apache htaccess ruleset: Try request as: 1) file as-is 2) file + .html suffix 3) DirectoryIndex 4) Else to index.php CMS router

I'd like to express this ruleset If the request is /hello then try the following in the given order: /hello — File of that name exists (file without file extension). Edit: Not a necessity. Only a ...
  • 143
0 votes
1 answer
47 views

Ban by IP and auto redirect to HTTPS

I'm trying to block access to the website for certain IP addresses. For this I have a file ipblacklist.conf with list of IPs in the following format one line per IP: Require not ip xxx.xxx.xxx.xxx ...
  • 113
2 votes
2 answers
1k views

.htaccess - Redirect all URLs with one exception

I want to redirect all URLs from one domain to another. Some of the old URLs have new counterparts with specific pages to redirect to. All other URLs should redirect to the homepage of the new domain. ...
  • 135
1 vote
1 answer
112 views

htaccess: 301 redirect defined URLs to new domain and catch all redirect the rest

I want to redirect some URLs from an old domain to new versions on a new domain. The old domain uses the www. subdomain and SSL. For example: olddomain.com/audi -> newdomain.com/cars/audi ...
  • 135
1 vote
1 answer
65 views

How Can We Do 301 Redirect Of Over 200 Pages To Corresponding 200 Pages At New Location?

I need help and need it fast. We recently migrated a subdomain to integrate with the domain. Eg. https://blog.example.com to https://www.example.com/blog https://blog.example.com has a ton of traffic ...
2 votes
2 answers
448 views

How can I remove 2 separate portions of a URL using mod_rewrite?

I have this unfortunate URL: dom.tld/library/Photography/index.php?cmd=image&sfpg=2021/*IMG_3468.jpg dom.tld/library/Photography/index.php?sfpg=2021/* This should look like this dom.tld/library/...
0 votes
0 answers
80 views

Rewrite subdirectory to root (Apache)

We have a mod_rewrite question here about going from subdirectory to "root" Here are a few strings : /fr/spil/spil-til-pc/steam/publisher/dovetail-games /fr/spil/franchise/little-nightmares/...
1 vote
1 answer
105 views

Apache mod_rewrite RewriteRule loops despite L flag

Apache/2.4.54. I am trying to achieve that similar URLs (e.g. "/anystuff.htm") are externally redirected to "/something" which internally is "something.html". But the ...
  • 113
0 votes
0 answers
64 views

Server 500 error caused by mod_rewrite with Apache

So i've been trying to get this particular script installer to run, and I cannot seem to figure out why it won't process the rewrites properly. In my .htaccess file within the root directory, I have ...
  • 101
0 votes
0 answers
39 views

How to server index.php from different directory through .htaccess?

I am working on a project which is in Yii2. I have to integrate swagger UI for API documentation. My current directory structure: This is what the .htaccess looks like: RewriteEngine on RewriteCond %{...
1 vote
1 answer
2k views

Can't get Apache rewrite to work on Docker PHP-Apache container

I've followed suit to quite some instructions, tutorials, and also questions in this forum, but I can still not get this working. I've setup a REST API using a PHP Apache Docker container, and need to ...
  • 145
0 votes
0 answers
305 views

Want to redirect URL and change slug to url parameter

I am stuck with a mod rewriting on Apache htaccess. my URL looks like this : http://localhost/Ac5GRnXW I want it to redirect like this: http://localhost/redirect.php?id=Ac5GRnXW I am using the ...
  • 1
1 vote
1 answer
39 views

htaccess syntax issue when moving script to a subfolder

I have recently purchased a script but this script only works in public_html folder . I need to install it in a subfolder named shop ( public_html/shop/ ) . Now the following .htaccess rules work ...
  • 33
0 votes
0 answers
20 views

Apache mod_proxy redirect

I have 2 domains, both on the same server. One of them is running a website. I have a subpage of that website that I want to map the other domain to. The goal is to have the domain www.something.com &...
  • 101
1 vote
1 answer
915 views

htaccess, block access a url with parameters

If I want to block access to example.com/path/?xxxx (xxxx is variable), but allow access to example.com/path/, how should I write it in my .htaccess?
  • 11
2 votes
1 answer
1k views

Redirect part of a URL parameter to the URL-Path

I used a module that created links like this: https://example.com/login?create_account=1&back=https://example.com/product/2164/?ets_rv_add_review=1 I need to redirect them to: https://example.com/...
  • 21
0 votes
1 answer
419 views

Apache mod_rewrite will not redirect from root folder to subfolder

I will preface this question by saying that I know next to nothing about Apache directives, but I need to use them in my project to hide the contents of the root folder, and also to hide the /public ...
1 vote
1 answer
84 views

RewriteCond rules from apache to nginx

RewriteCond %{TIME_SEC} >40 RewriteCond %{TIME_SEC} <56 RewriteRule ^(.*)the-product(.*)$ https://www.%{HTTP_HOST}/%{REQUEST_URI} [R=301,L] I want to convert it to nginx but there is no ...
1 vote
1 answer
256 views

.htaccess redirect if param value not portuguese-pt (FORCE WHMCS ONLY ONE LANG)

I need help to redirect URLs with multiple language codes to one with .htaccess. The following URLs should redirect: https://example.com/cp/cart.php?a=add&pid=7&language=us https://example....
1 vote
0 answers
124 views

Automatically remove Set-Cookies

I have a php web application. This web application sets some cookies. I want to write a .htaccess which remove on the fly this cookies. Here is what I've done, with mod_header: Header unset Set-Cookie ...
  • 279
-1 votes
1 answer
37 views

Simple IP/URL Redirection

We have a web application that each user has their own address like our-app.com/user1. Our users want to use their own domain and redirect to their pages on our app. For example www.user1.com => ...
  • 99
0 votes
0 answers
143 views

Apache web server - How to serve custom error page when 401 returned from proxypass site

So I have an apache web server with the below rule: ProxyPass /auth https://my-auth-server.azurewebsites.com/auth keepalive=On ProxyPassReverse /auth ...
0 votes
0 answers
188 views

Convert multiple Apache/.htaccess files to Nginx config

main .htaccess # BEGIN WordPress # The directives (lines) between "BEGIN WordPress" and "END WordPress" are # dynamically generated, and should only be modified via WordPress ...
  • 1
-3 votes
1 answer
23 views

Edit mod_rewrite [closed]

Now, this is a very simple question but I'm new to this topic. To test my website, I'm using a virtual machine (Oracle VM). I'm using ubuntu with apache2. I want to edit mod_rewrite to, of course, ...
3 votes
2 answers
867 views

seo friendly url not working

I have a folder structure like the below www.exampe.com/distributor/index.php and I want to access the file via an seo friendly www.example.com/distributer/abcinc and then in the index.php want to ...
  • 145
3 votes
1 answer
106 views

Apache2 mod rewrite extremely slow, on one server only

I have a site on my local ubuntu dev box with some mod rewrite rules, which we are attempting to use to force google and other bots to index the correct page, rather than our ajax snippets as they ...
  • 41
0 votes
0 answers
26 views

apache mod_rewrite path to querystring - keep base directory

I try to "beautify" my URLs from eg. www.example.com/page.php&id=3 to www.example.com/page/3 I can achieve this with: RewriteEngine On RewriteRule ^(page)/([0-9]+)$ page.php?id=$2 The ...
  • 1
0 votes
1 answer
162 views

Error: The response is not a valid json response. WordPress Windows server

I personally rented a Windows virtual server and installed and set up mysql+phpadmin+IIS and after that I started my email server and tested it and everything was ok, then I installed WordPress and ...
  • 1
0 votes
0 answers
107 views

ProxyPass to dynamic socket path based on URL path

We’re developing a web application and any Git branch can be deployed to a branch-specific directory per click in our Gitlab CI pipeline. I want to make those branches available via Apache HTTPd ...
0 votes
0 answers
21 views

htaccess sudomain opens directory of root domain

I have redirected all subdomains to my main domain with the UI of my webhoster (*.domain.com -> domain.com) Htaccess in the root (rewrite all subdomain requests to a corresponding named folder in a ...
1 vote
0 answers
25 views

Rewrite rules for all but one directory (recursive)

We need to do a rewrite for a subdirectory of a site to its own host, with the exception of one directory. We also need to be sure that the original subdirectory is dropped in the rewrite. (using ...
0 votes
0 answers
160 views

Apache mod_rewrite solution to route requests for a domain to a subfolder

I have a use case where I have multiple domains (e.g., x.com, y.com, etc) sending requests to the same Apache web server (running under Docker). I would like x.com requests to go to /var/www/html/x ...
0 votes
0 answers
180 views

reverse proxy Apache that redirects filtering by ip and path

I am trying to create a reverse proxy with apache that if it receives a request with /thisismypath as path and the ip address that make that request is 192.168.2.12 the it should redirect to 192.168.1....
  • 1
0 votes
0 answers
35 views

Redirect to other ip but the same query whit Apache mod_rewrite

I have to redirect the request that a Apache web server receives, using the user_agent to filter. The idea is that if the user_agent is "Mozilla/5.0 (Macintosh; Intel Mac OS X 12_2_1) AppleWebKit/...
  • 1
0 votes
0 answers
55 views

Apache VirtualDocumentRoot multiple subdirectories possible

I have a local Apache server for developing pages. Therefore, I have a root folder where all the different pages are in subfolders. Those folders then have another subfolders for the public content. ...

1
2 3 4 5
45