Questions tagged [mod-rewrite]
mod_rewrite is an Apache module that allows for server-side manipulation of requested URLs.
2,215
questions
0
votes
0
answers
15
views
Why is adding this line to my mod_rewrite creates looping issue, and how to avoid it?
I pasted below the existing mod_rewrite section of the .htaccess of my Magento site.
I need to modify it to implement a short URL scheme that would redirect all requests like mysite.com/-jk7ASD63 (all ...
0
votes
1
answer
45
views
Apache how to find cause of 404 with rewriterule ignored
So I have this
RewriteCond %{REQUEST_URI} (da-dk)/(.*)(/|\.php)$
RewriteRule ^(da-dk)/(.*)(/|\.php)$ /$2$3 [L]
But for some reasons example.com/da-dk/ gives "404 - not found"
I would like ...
1
vote
0
answers
29
views
Apache Rewrite Based on Query String
I'm trying to detect the presence of a particular name/value pair in the query string and, if it exists, do a thing. I'm trying to do this in a conf file that's stored in conf-available/ and after ...
2
votes
2
answers
267
views
Apache on debian don't redirect http to https correctly
Debian 11
config file: /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
...
0
votes
1
answer
28
views
How to add apache server config rewrite rule for encoding pipe symbol in url
I am getting a 404 error on URL that contains pipe symbol. If I encode manually with %7C for pipe it works properly. I want to add a rule in Apache conf file that automatically replaces pipe character ...
1
vote
1
answer
59
views
rewrite based on script in URL
Using Apache 2.2.x -- my usual approach to blocking script kiddies from looking for various scripts on the server is to use dynamically created 'deny from' lists with the offending ip's. Works, but is ...
0
votes
0
answers
48
views
How to use Apache's mod_rewrite to change the HTTP version in a request?
I have an old system sending a POST to an old version of Apache(2.4.9) that is not sending the HTTP version. The old system has no issue but I want to update Apache to the latest. When I do, Apache ...
1
vote
1
answer
49
views
Apache 2.4 expr - how to load a html file via RewriteRule?
On Apache 2.4, Having a bunch of mixed SEO friendly and dynamic URLs on an ecom site I want to implement a simple caching system for my blog posts and product pages. First I want to have md5(...
1
vote
1
answer
73
views
How to replace custom url old domain to new domain with .htaccess
How to replace all url entire website with new domain and new permalink? I have 5k url to replace at my site.
Example :
Current URL: oldomain.com/2020/12/data-raid-4963.html
Replace To: sub.newdomain....
0
votes
0
answers
22
views
How to write parameter URL in .htacess Rewrite
I want to point this URL in .htaccess:
http://www.example.com/furniture/chair/foldingchair
to
http://www.example.com/products.asp?catID=1&SubID=2&SubCatID=3
where
catID=1 = furniture
SubID=...
0
votes
0
answers
8
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
vote
1
answer
143
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. ...
0
votes
0
answers
24
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
222
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
15
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
38
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 ...
0
votes
0
answers
60
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-...
0
votes
0
answers
25
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 ...
0
votes
1
answer
56
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
vote
0
answers
83
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:
...
1
vote
1
answer
36
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
18
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.
0
votes
1
answer
26
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....
1
vote
1
answer
238
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
20
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
vote
1
answer
251
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 ...
0
votes
1
answer
96
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
...
2
votes
2
answers
2k
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.
...
1
vote
1
answer
253
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
...
1
vote
1
answer
90
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
518
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
105
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
230
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 ...
0
votes
0
answers
94
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 ...
0
votes
0
answers
40
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 %{...
2
votes
1
answer
4k
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 ...
0
votes
0
answers
436
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
vote
1
answer
64
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 ...
0
votes
0
answers
24
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 &...
1
vote
1
answer
1k
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?
2
votes
1
answer
2k
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/...
0
votes
1
answer
621
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
110
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
301
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
197
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
...
-1
votes
1
answer
38
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 => ...
0
votes
0
answers
180
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
232
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 ...
-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
999
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 ...