Questions tagged [mod-rewrite]

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

For an introduction and examples of using mod_rewrite, read over the comprehensive article,
"Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask"

2224 questions
1
vote
3 answers

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 installed the app "Rocket.Chat". This installs…
pixel24
  • 11
  • 1
1
vote
1 answer

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 to be served by my main host/server. I have tried…
argyrodagdileli
  • 101
  • 2
  • 8
1
vote
1 answer

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 "example.com" Is there anyway to make a "global" rewrite,…
Adam Larsson
  • 31
  • 1
  • 6
1
vote
2 answers

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 following rule: RewriteEngine On RewriteRule…
cat15ets
  • 21
  • 1
  • 3
1
vote
1 answer

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 mydomain.com to www.mydomain.com. I would like to be…
Darrell Brogdon
  • 137
  • 1
  • 1
  • 11
1
vote
1 answer

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 question is, how can I add the X-Requested-With request…
Jeff
  • 1,416
  • 3
  • 28
  • 50
1
vote
0 answers

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 data to a collect file with AJAX but I get 302…
Emre6
  • 151
  • 2
1
vote
2 answers

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 root is set to be "/var/www/html/public" but I…
cr001
  • 195
  • 2
  • 8
1
vote
0 answers

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 ProxyRequests Off KeepAlive On ProxyPreserveHost Off …
1
vote
1 answer

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 in /var/www/public_html/domain123.com with the…
iraqiboy90
  • 21
  • 4
1
vote
1 answer

Help with mod_rewite rule

I have a rule that will get the extension of every file from the url. I need to match all jpg, gif, png and bmp files. This is for a watermark application. Currently, it only matches jpg and Jpg. Can someone help me match all four extensions? Here…
timmay
1
vote
0 answers

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 past with something like WordPress I would put this…
MrCarrot
  • 345
  • 1
  • 4
  • 13
1
vote
1 answer

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.com/knowledgebase/ [QSD,R=301,L,NC] However,…
alancc
  • 141
  • 12
1
vote
1 answer

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 subdirectory: mywebsite.com/folder_a/ -->…
Ale Morales
  • 113
  • 3
1
vote
1 answer

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-host.com/current-year/my-page.html Any ideas how…
mrjayviper
  • 187
  • 1
  • 11