2022 Developer Survey is open! Take survey.

Questions tagged [mod-rewrite]

URL rewriting module for Apache web servers

Filter by
Sorted by
Tagged with
0 votes
0 answers
5 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....
user avatar
  • 1
0 votes
0 answers
17 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/...
user avatar
  • 1
0 votes
0 answers
11 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. ...
user avatar
0 votes
1 answer
22 views

Redirect all pages to non www and one page to www

I want to redirect all my internal pages (eg: example.com/about) to their non-www version but I want my homepage (https://example.com) to redirect to its www version (https://www.example.com). I ...
user avatar
0 votes
0 answers
48 views

Apache2 behind NGINX: MOD_REWRITE only works without HTTPS

For days I can't get my head around the following problem: We have an application (Faveo) which has two requirements for going through the setup wizard: HTTPS & MOD_REWRITE. Faveo is running on ...
user avatar
1 vote
1 answer
15 views

RewriteCond for APIKEY

I am trying to create a RewriteRule which looks at the incoming Header for an APIKey and if it contains a matching string then it will redirect to respective URL else, it should be inaccessible. I am ...
user avatar
1 vote
1 answer
23 views

On Apache how to switch off DirectorySlash only for requests to a specific subdomain?

Served by Apache I'd like on one subdomain site of mine (say sub.mydomain.com) that URLs without trailing slashes point directly (without external redirect) to the index file in the underlying folder. ...
user avatar
  • 111
1 vote
1 answer
18 views

Forbidden on everything except for scripts located on subfolders

I want to forbid everything coming on a specific domain (e.g. example.com) except for some entry points (here, PHP files) located on a specific path (e.g. example.com/subfolder1/subfolder2/script.php)....
user avatar
  • 13
1 vote
1 answer
139 views

Trying to get Apache to serve webp instead of png/jpg (from /img folder of prestashop)

First post here, so I hope I did it well. I converted all png/jpg starting from my prestashop public_html folder to webp, and added rewrite rules to the .htaccess in order to have the webp served ...
user avatar
  • 13
1 vote
1 answer
26 views

Add a subdomain as an exception in hotlinking

I used this code in my .htaccess file and it is working great to prevent hotlinking: RewriteEngine On RewriteCond %{HTTP_HOST}@@%{HTTP_REFERER} !^([^@]*)@@https?://\1/.* RewriteRule \.(gif|jpg|jpeg|...
user avatar
  • 11
1 vote
1 answer
39 views

Consolidating many VirtualHosts into one block, is this a job for SetEnvIf?

Edit I think what I need here is SetEnvIf I'm attempting to consolidate all of my port-80 VirtualHosts into one block for convenience, but I'm struggling with the final piece of the puzzle. All port ...
user avatar
  • 1,374
1 vote
1 answer
32 views

RewriteRule won't match if trailing slash present, throws nginx 404

With this .htaccess... RewriteEngine on RewriteRule ^foo$ foo.php RewriteRule ^foo/$ foo.php ...I get the following behavior, when I request /foo — works, I get foo.php /foo/ — fails unexpectedly ...
user avatar
  • 121
1 vote
0 answers
94 views

Apache reverse proxy to site using NTLM authentication fails with mod_rewrite but not mod_proxy

We have a reverse proxy server in front of an Exchange server and would like to lock down more of the paths. Minimized examples: Fails (but works for all pages that don't require authentication): <...
user avatar
  • 221
1 vote
2 answers
36 views

.htaccess mod_rewrite not catching all RewriteRules

There is a PHP application with a PHP router as entry point for all the requests placed inside index.php. I am trying to write a .htaccess file to forward every request to index.php except for API ...
user avatar
  • 113
0 votes
0 answers
27 views

Rewrite url transparently in Apache

I am needing to deploy a new frontend application on NextJS which is operating as a transition for a legacy WordPress site using the incremental adoption functionality in NextJS. We are looking at an ...
user avatar
1 vote
3 answers
32 views

Hide path in URL of Rocket.Chat with mod_rewrite

I have been looking for a solution to my problem for days. Unfortunately without success. Before I try now days further around and it in the end no solution I ask you. On my Univention server I have ...
user avatar
  • 11
1 vote
1 answer
55 views

Apache 500 Error when proxying api subdirectory

I am trying to redirect PUT request for a specific endpoint to another host. The said endpoint resides under /internal and accepts only PUT requests. The other endpoints under /internal will continue ...
user avatar
0 votes
1 answer
39 views

Redirect works, pass-through does not

Our CMS has a handler named root, which works: http://example.com/root serves, what we want it to serve. We'd like requests for "naked" domain (http://example.com) to be handled by that same ...
user avatar
  • 2,242
0 votes
0 answers
90 views

Language based RewriteRule like mysite.com/en/ in .htaccess

I'm trying to write redirect directives in the .htaccess to forward internally all user requests like this: Every request in a language folder should redirect to the requested file with the language ...
user avatar
  • 53
1 vote
1 answer
39 views

Apache http to https WITHOUT any adress?

a normal http to https rewrite could look like this: RewriteEngine On # RewriteCond %{HTTP_HOST} !^example.com$ # RewriteRule /.* https://example.com/ [R] but this code specifies the site to "...
user avatar
0 votes
2 answers
147 views

Htaccess to rewrite URL with two parameters

I want to rewrite this type of URL https://mywebsite.com/content/page.html?id=12&title=my-page-title to https://mywebsite.com/12/my-page-title.html Using generateit.net/mod-rewrite/ I got the ...
user avatar
1 vote
1 answer
31 views

How to make mod_rewrite force a redirect?

I have a need to temporarily redirect my website to a static version hosted on Cloudflare. The current site is a Wordpress site hosted at Ionos and Wordpress seems to be doing a 301 redirect from ...
user avatar
2 votes
1 answer
38 views

Apache incorrect url rewrite for non-existent symlink files

I have a directory (foo/uploads), which contains 1 file: file1.txt I have created a symlink to this directory (bar/uploads) Here is my .htaccess file inside bar: RewriteEngine On RewriteCond %{...
user avatar
  • 153
0 votes
0 answers
37 views

AWS Lightsail LAMP PHP7 mod-rewrite

I just installed a fresh AWS Lightsail LAMP stack with php7.4 and a lets encrypt ssl Docs say Mod-rewrite is installed/enabled by default however I get a 404 when I go to any url on my site that is ...
user avatar
  • 103
0 votes
0 answers
39 views

How does this RewriteRule allow certain to access a file in a protected folder?

I'm trying to understand how this RewriteRule code works: RewriteRule private/([a-zA-Z0-9]+)$ index.php?bua_v2_pf=$1 [L] RewriteCond %{REQUEST_FILENAME} -s RewriteRule content/images/protected(\/[A-Za-...
user avatar
  • 101
1 vote
1 answer
87 views

Is it possible to detect an ajax request with Apache 2.4 for a mod_rewrite rule?

Is it possible? Trying to move my script security to the server-level. With PHP, just check if $_SERVER['HTTP_X_REQUESTED_WITH'] is set to XMLHttpRequest (jQuery added). I guess maybe a better ...
user avatar
  • 1,374
1 vote
0 answers
30 views

When the ".php" at the end of PHP Files is removed, it becomes 302 redirect

I remove the .php file attachment in the application, but this time the application's action pages do not work. Because I removed the .php suffix at the end of the files. For example, I want to send ...
user avatar
  • 151
4 votes
1 answer
250 views

use "rewrite" and "try_files" together [Nginx]

I removed the ".php" suffix at the end of the PHP files on the Nginx server with the following code, but this time I cannot send some data to the server. try_files $uri/ $uri.html $uri.php$...
user avatar
  • 151
1 vote
2 answers
50 views

How to use Mod Rewrite to access non-document-root folder files?

I have the following structure for my website codes at /var/www/html -- files ---- test.txt -- app ---- SomePhpCodes.php ---- SomePhpCodes.php -- public ---- index.php ---- .htaccess The document ...
user avatar
  • 185
1 vote
0 answers
213 views

Apache Reverse Proxy rewrite rule for complex URL. "Too Many Redirects" error

I am trying to configure a reverse proxy to my backend server. This is my previous configuration which is working. Define REMOTE_ADDR proxyserver.domain.com <VirtualHost *:443> ...
user avatar
1 vote
1 answer
60 views

htaccess rewrite rule not working with file extentions

I have two domains setup on the same folder on a server. i.e. dl.d123.com @ /var/www/public_html/dl.domain123.com dl.domain123.com @ /var/www/public_html/dl.domain123.com I have an htaccess file ...
user avatar
0 votes
0 answers
35 views

"rewrite" structure for subdomain on Nginx

I want to do a custom rewrite for the subdomain on ISPconfig. When I add the code below for this, the subdomain is redirected to the main domain. Sample #1: server { ... if ($http_host = "...
user avatar
  • 151
0 votes
0 answers
40 views

Hide your paths/filenames in apache

in Apache 2.4, can I hide all "paths" from the browsers? if somebody are on https://example.com/users/list.html it would only say https://example.com in the addressbar, and if someone takes ...
user avatar
0 votes
1 answer
59 views

Apache, redirect for a moved directory

On our webserver a directory has been "copied" from one location to another. Now the original location is gone however I am receiving requests to provide a redirect to the new location. I ...
user avatar
1 vote
0 answers
32 views

Increase PHP's upload_max_filesize in Apache

I have a Laravel app and I need to increase PHP's upload_max_filesize, but rather than do this for the entire app I wanted to apply it to a specific route/location. I am running Apache 2.4. In the ...
user avatar
  • 345
2 votes
1 answer
112 views

Why the redirection in .htaccess not work?

I have a Wordpress website. I want to redirect .php urls to the ones without the .php suffix. The .htaccess is as follows: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On ...
user avatar
  • 133
1 vote
1 answer
205 views

What does %{REQUEST_FILENAME}.ext mean? Why the extra .ext ending?

The %{REQUEST_FILENAME} contains a string like this: /web/webroot/index.php I see a lot of people recommend testing if a file exists and has a .php extension like this: RewriteCond %{REQUEST_FILENAME}...
user avatar
  • 1,374
1 vote
1 answer
792 views

Should I escape slash '/' in RewriteCond?

Whether I need to escape the slash '/' in RewriteCond? Currently I write the following rule in .htaccess: RewriteCond %{QUERY_STRING} rp=/knowledgebase/ RewriteRule ^index\.php$ https://www.datanumen....
user avatar
  • 171
1 vote
1 answer
85 views

Exclude google doc embed iframe from nginx rewrite rule?

I hope that someone can help me here as I have very limited knowledge about server related stuff. I have a WordPress site where I want to limit the /wp-content/uploads/ directory access to logged in ...
user avatar
  • 11
1 vote
1 answer
108 views

Is is possible to change a path's root folder with .htaccess?

I have a website set up with its own root directory in the common configuration: mywebsite.com --> /path/www/mywebsite And them pathnames on mywebsite get naturally mapped to their corresponding ...
user avatar
1 vote
1 answer
162 views

apache rewrite: how do I check for empty or not present query parameter?

might be best explained with an example: - If I enter either URLs in my brower - www.myhost.com/my-page.html?year= - www.myhost.com/my-page.html - I then want to get redirected to www.my-2nd-...
user avatar
0 votes
0 answers
34 views

Cannot block YandexBot with mod_rewrite

We have an Apache httpd 2.4 server as our point of entry for about 20 web sites and each site has its own virtualhost configuration. A lot of settings are probably redundant but it suits our needs. ...
user avatar
1 vote
1 answer
199 views

Apache mod_rewrite/mod_redirect: convert URL with query parameters into an SEO-friendly URL. some query parameters are ignored

As above. might be best explained with an example: original URL (the order of the params is NOT consistent) www.myhost.com/my-page?p1=v1&p2=v2&p3=v3 OR www.myhost.com/my-page?p2=v2&p1=v1&...
user avatar
1 vote
1 answer
68 views

RewriteRule is applied to all files during directory listing

With Options Indexes and LogLevel rewrite:trace6 I see that my rewrite rule is applied to all files in the directory being listed. It even goes inside sub-directories and looks for index.html. This is ...
user avatar
  • 538
0 votes
1 answer
60 views

How do I redirect URL while also changing source and destination IP address over HTTPS?

I have a SaaS service which exposes an URL (let's say (https://mylink.foo.com) that is only accessible from some whitelisted IPs. However we now need the aforementioned URL to be accessed by an ...
user avatar
0 votes
0 answers
42 views

Apache cookie based site access

I store a single cookie in a file and want to retrict access to users who have that specific cookie set (with a specified name) and redirect others (from any page in the site) to my site's root. Since,...
user avatar
  • 1
0 votes
0 answers
34 views

Apache http to https rewrite triggering for all requests

I have the following in a virtual host: RewriteEngine on RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} It works to redirect everything to HTTPS, but the problem is it ...
user avatar
  • 101
1 vote
1 answer
153 views

Website root trailing slash auto-removed (issue)

as per title, when I enter my website URL manually (examples at the end of the topic), the trailing slash at the end of the domain being removed automatically. I have SSL redirect forced and Apache ...
user avatar
1 vote
1 answer
72 views

Apache 2.4 Convert .htaccess and rewrite it to vhost.conf

I am rewriting the Apache 2.4 configuration that I've received from the old development team. I have ~200 lines of similar configuration, and I can not understand on what principle I need to change ...
user avatar
0 votes
1 answer
124 views

Apache2 mod_rewrite seemingly not doing anything

I'm having difficulty getting mod_rewrite to work in Apache2 on Debian 10. I enabled the extension with a2enmod rewrite systemctl restart apache2 And had no errors and can see the module in apachectl ...
user avatar

1
2 3 4 5
44