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
0
votes
0 answers

Apache mod_rewrite fails http > https

I'm trying to redirect all http traffic for www.example.com to https://www.example.com, here's my apache2 config: ServerAlias example.com *.example.com ServerName www.example.com Redirect permanent /…
batflaps
  • 179
  • 1
  • 3
  • 10
0
votes
1 answer

Apache HTTPD rewrite backend proxy HTTP error 500 to 503

I have two use cases: HTTPD is a proxy for a Tomcat application HTTPD is a proxy for a PHP application For compliance and security needs all 50x errors must be rewritten to 503 prior to sending back to a client. Exposing 50x errors leaks…
Phil
  • 71
  • 2
  • 5
0
votes
1 answer

RewriteCond & RewriteRule to correctly redirect and override the status of 301 in the .htaccess file

I have an Android app that loads a script http://example.com/apps-support/ads/ads.php?appName=my_app (my_app may change). My hosting provider made some changes on the server a few days ago and the above script began to return 301 Moved Permanently…
Nolesh
  • 101
  • 1
0
votes
0 answers

Rewrite URL to CAPITALIZE one word

In an attempt to preempt all of the comments I'm surely going to get telling me that this is a terrible idea and that it's bad for SEO... I fully understand the repercussions of what I'm asking. However, due to the nature of the project I'm working…
0
votes
1 answer

Multiple redirects with 301 apache from https://domain.tld to https://domain.tld/subdir/

I have the current setup with Apache2, lets encrypt to move http://domain.tld => https://domain.tld http://www.domain.tld => https://www.domain.tld Its working perfect, Now I wanted move all my domainname visit to a subdir http://domain.tld =>…
indianwebdevil
  • 220
  • 1
  • 6
0
votes
1 answer

Convert this .htaccess to nginx

I am having some problems trying to translate this to nginx, today I can't make my brain to work well and solve this! RewriteEngine on RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(.*)$ $1 [L] RewriteRule ^(.*)$ …
zebazv
  • 1
0
votes
1 answer

ModRewrite: Stop Running Rules Twice for Silent Redirects?

Consider this simple rule to hide an ugly URL from the visitor: RewriteRule ^/CleanPage.html$ /index.php?ugly_parameter=yuck&somevar=12 [L] This rule seems to be producing two sets of "rule runs" in the log. First, it runs all the rules, until it…
Nick
  • 4,503
  • 29
  • 69
  • 97
0
votes
1 answer

ModRewrite: Redirect anything but Root "/"?

I'm trying to do something incredibly simple: If the user requests the home page, http://www.OurSite.com/, then stop all rules and serve the file normally. If anything else in the world is requested, silently redirect to a php script. I'm using…
Nick
  • 4,503
  • 29
  • 69
  • 97
0
votes
2 answers

Trying to modify display of my url for html index page

What I would like to do is serve up a file such as "index.html" and have the url read mysite.com/boat-repair/electrical-system-repair. I tried putting the target file in a series of sub directories hoping the directory names would show in the…
0
votes
1 answer

Apache 2.4 vhost configuration - How to "hide" parts of the url for CMS and browser

Apache 2.4.38 on Windows We are just about to start using a new content management system, Enonic, hosted in the cloud. I am now trying to configure an internal alias for the test instance to point to the instance in the cloud. This is quite…
rhellem
  • 295
  • 1
  • 5
  • 14
0
votes
0 answers

Ubuntu Apache2 php7 LAMP server mod_rewrite not working

I just setup a new AWS EC2 LAMP Stack (using the aws marketplace). the server has php7, Apache2 Now my issue is I would like to use mod_rewrite so that I can go to urls like www.mydomain.com/contact instead of www.mydomain.com/contact.php However…
Jayreis
  • 145
  • 15
0
votes
2 answers

What should I have here for my .htaccess file

I have a wordpress blog that is installed on the root of my domain. I have put another piece of software in a subdirectory. When I try to access the subdirectory (http://www.blah.com/abc) I get a 404 error from wordpress. I've done some reading and…
GeoffreyF67
  • 497
  • 2
  • 7
  • 14
0
votes
0 answers

New line in apache rewrite rule

Using RewriteMap in Apache 2.4 for some variable conversion referring this. Everything seems fine. Able to test the external program alone and it gives the expected output. As per the link, the map key has to be terminated with new line. I do…
Anitha.R
  • 101
  • 2
0
votes
2 answers

Why does this RewriteRule cause an Internal Server Error?

I call my site this way locally: http://localhost:80/mysite/de/layer1/layer2/module In .htaccess I have: RewriteEngine on RewriteRule !^((css|js|images)/.*)$ index.php%{REQUEST_URI} [L, NE] I try to rewrite that…
openfrog
  • 235
  • 1
  • 4
  • 8
0
votes
1 answer

How to redirect one route from a domain some where else in apache

I have what, from my searching so far, seems to be a slightly different problem with site redirections than the norm. I need to redirect one particular route from one domain to another on a different port. So far I've tried a simple 301 Redirect and…
Peter Nunn
  • 452
  • 1
  • 11
  • 25