Questions tagged [mod-rewrite]

URL rewriting module for Apache web servers

Filter by
Sorted by
Tagged with
0
votes
0answers
19 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 ...
0
votes
0answers
17 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-...
1
vote
1answer
15 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 ...
1
vote
0answers
23 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 ...
3
votes
1answer
67 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$...
1
vote
2answers
22 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 ...
1
vote
0answers
35 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> ...
1
vote
1answer
39 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 ...
0
votes
0answers
27 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 = "...
0
votes
0answers
31 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 ...
0
votes
1answer
26 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 ...
1
vote
0answers
20 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 ...
2
votes
1answer
65 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 ...
1
vote
1answer
56 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}...
1
vote
1answer
720 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....
1
vote
1answer
43 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 ...
1
vote
1answer
26 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 ...
1
vote
1answer
38 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-...
0
votes
0answers
16 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. ...
1
vote
1answer
54 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&...
1
vote
1answer
43 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 ...
0
votes
1answer
35 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 ...
0
votes
0answers
33 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,...
0
votes
0answers
24 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 ...
1
vote
1answer
67 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 ...
1
vote
1answer
59 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 ...
0
votes
1answer
56 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 ...
0
votes
0answers
29 views

Apache rewrite condition not matching, possibly bad syntax?

Hi so I have a rewrite rule in order to control access to the admin page of a service behind a reverse proxy. I only want local ip's to be able to access it. So essentially if the condition does NOT ...
1
vote
1answer
104 views

Rewriterule not working with Joomla urls due to question mark and other special characters, also due to long urls

So I moved from Joomla CMS and now I need to finish my permanent redirects, but the following redirect isn't working (it's actually returning an error 404): RewriteCond %{HOST_NAME} =&?$ #...
0
votes
1answer
56 views

How can the Apache httpd root path be rewritten to a subdirectory?

While I have seen similar questions elsewhere, some of those questions ask about redirecting the exact root path or else the provided answers don’t always work properly. What I require is to rewrite ...
0
votes
1answer
84 views

Apache2 Virtual Host Proxy Forward

Hi all I am trying to use a virtual host to forward streaming.fusion.tk to my internal emby server form my webserver. I have setup a config file called streaming.conf in /etc/apache2/sites-available/ &...
1
vote
1answer
22 views

How to load requested file from sub-directory without rewriting base

Utilizing .htaccess rules, I'm attempting to load a file from within a sub-directory while keeping the frontend URL unchanged if both the domain and file path match criteria. Example of URL: example....
3
votes
1answer
527 views

htaccess rewrite /dir/*.jpg to /dir/webp/*.webp only when webp file exists

I'm trying to rewrite all website files (*.jpg|*.gif|*.png) to *.webp in a subdir, but only when the *.webp file exists. Previous and new files have the same name, only changing the extension and *....
2
votes
1answer
90 views

NGINX Redirect to Cached File in Subfolder

I have a program that creates optimized versions of pictures that are uploaded to the /images/ folder on the web server. It traverses subfolders and in each one, creates a .optimized folder that holds ...
1
vote
1answer
46 views

RewriteRule with flag [L] stopping caching?

I use server management software plesk with apache and nginx. I set in apache and nginx a expired header for javascript files for one year. That's working. I can see one year for "expires" ...
1
vote
1answer
80 views

After installing script all subdomains go to the main domain

I have a main domain www.example.com. and the following subdomains under the main domain support.example.com test.example.com Previously both subdomains are working fine. But after installing a PHP ...
2
votes
1answer
92 views

When changed to WWW, all URLs showing index.php?page= how to remove index.php?page=?

I recently managed to direct all URLs from non-www to www as I had an SEO error regarding duplicate websites. Once I have applied www rules then all my URLs start showing index.php?page= which doesn't ...
0
votes
0answers
32 views

Exclusion in Rewrite Rule

I have a rule in .htaccess redirecting all HTTP requests to HTTPS. I need to exclude two specific paths because they are called by a legacy application to download a file, connecting using TLS 1.0 (...
0
votes
1answer
28 views

How to redirect search.php?query=test&search=1&s=1 to /query/test

I have tried other things, but I cannnot get it to work, when I go to the main website, (index.php is just a include of search.php) it will send me to this /query/search.php/search.php/search.php/...
0
votes
0answers
18 views

Apache recursive rewriting rules

I'm writing a PHP CMS and, for each page, I can have a subpage, and a page number, and a language switch, and a previous version. Then, I can edit a page, or call a special page. Examples : http://...
3
votes
3answers
1k views

Apache: Return static string for location

For a .well-known path, I want to return a static JSON file/string. With nginx, this seems to be possible without creating that file by specifying the content in the configuration file: location /....
-1
votes
1answer
28 views

Modify Apache rewrite rule for Nginx

How to rewrite this Apache rewrite rule for Nginx? RewriteCond %{REQUEST_URI} ^/api RewriteRule (.*) index.php [L] I tried this but it doesn't work, I'm getting HTTP 404 in /var/log/nginx/access....
1
vote
1answer
37 views

Redirect the document root and a specific page only to another domain

Might sound confusing, but what I want to achieve is this: If the user visits: www.mydomain.com (with or without www.) transfer them to: www.myotherdomain.com/welcome-old-users At the same time, I ...
2
votes
1answer
152 views

Apache: Don't log errors for certain non-existing files (regular file or symbolic link)

I want to prevent Apache from logging "File does not exist" errors for certain irrelevant non-existing files that are often requested, such as "apple-touch-icon-120x120.png". These ...
0
votes
1answer
81 views

Forwarding Apache SSL-Port to Web-App on localhost

I'm struggeling for days now to route a subdomain with SSL to a local running vue app, specifically the directus admin ui. I've done this before, like with the tool monit, and it worked like a charm: &...
0
votes
0answers
128 views

Application alias rewrite using apache

I am new to apache and i am trying to rewrite an application default alias to a more elegant one using apache but unfortunately i struggle and i can't find a way to do it Can you help me please ? What ...
1
vote
1answer
256 views

Apache rewrite causes server error 403 when genuine directory exists after extension removal rewrite

I've spent a couple of days now trying to create a specific rule set that will allow me to remove .html extensions from all the files in the directory and present neater URIs. I'm using a .htaccess ...
1
vote
1answer
481 views

Rewrite instead of redirect with Azure Web App/Linux

I'm trying to configure rewrite rules with .htaccess on an Azure Web App with Linux+Apache(+PHP), however I can only get redirects to work (but no rewrites). The source is structured as following: ./....
1
vote
1answer
25 views

Space in value part of RewriteMap

This question is related to Apache RewriteMap with URLs containing space doesn't work, but in this case the issue is a space in the value part of the map, not the key part. Say I have this entry: /...
0
votes
2answers
77 views

Mod-rewrite Port in Apache2

I'm playing with home assistant (HA) in docker on Ubuntu 20.04. HA is hosted on port 8123. HA does not support subpaths, ie. it is hosted at MYDOMAIN.duckdns.org:8123 rather than MYDOMAIN.duckdns.org:...

1
2 3 4 5
43