Questions tagged [mod-rewrite]

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

482 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0 votes
0 answers
49 views

Redirecting site to HTTPS and www using htaccess

I have used this code in my .htaccess file: RewriteEngine On RewriteCond %{HTTP_HOST} ^silkgifts.co.uk RewriteRule (.*) https://www.silkgifts.co.uk/$1 [R=301,L] it directs my HTTPS non-www to the ...
sue's user avatar
  • 1
0 votes
0 answers
27 views

Yet another mod_rewrite - how to achieve desired result

I would really appreciate some help with a mod_rewrite, I know there is 64K answers on Stack Exchange about this topic and my answer is probably in there somewhere if only I could find the ones to put ...
user424701's user avatar
0 votes
0 answers
97 views

Restricting redirects using RewriteCond on a drupal multisite

I am working on a drupal multisite, therefore, my redirects get added to the same htaccess. The problem is my RewriteCond are not working correctly. My RewriteRule for example1.com is also working ...
Ronnie's user avatar
  • 113
0 votes
1 answer
52 views

In Apache, is it possible to serve data from one URL while displaying a separate URL in the browser?

I have a multilingual web application that depends on a language code being in the URL. Example: example.com/zh-hans/title The client now wants a new structure: example.com/cn/title The problem ...
user658182's user avatar
0 votes
0 answers
155 views

Angular2: apache2 on osx with mod_rewrite

I am getting a strange behaviour while trying to setup an apache2 virtual host with mod_rewrite for an angular2 app. I am not using HashLocationStrategy, http://host.tld/#page but the default ...
pop's user avatar
  • 101
0 votes
1 answer
110 views

Apache .htaccess: do not redirect if

I'm struggling to find out how to perform the following redirection via .htaccess and it's driving me a bit crazy. Scenario: If requests points to one of the following paths, do not perform any ...
jrance's user avatar
  • 1
0 votes
1 answer
51 views

Apache and URL rewriting to different names

First off I am running on windows for my sins. I have two tomcat instances of the same web application running on two different ports & I can access both OK directly http://localhost:7070/foo/...
Bill Comer's user avatar
0 votes
0 answers
117 views

Basic authentication in subdir breaks RewriteRules of parent dir?

In /public_html/.htaccess, I've got rewrite rules as follows: RewriteRule ^(subdir1)($|/) - [L] RewriteRule ^(subdir2)($|/) - [L] RewriteCond %{HTTP_HOST} ^(www.)?example.com$ [NC] RewriteRule ^(.*)$...
J23's user avatar
  • 113
0 votes
0 answers
77 views

Mod rewrite does not include optional url components

I have this rewrite RewriteCond %{HTTP:x-requested-with} ^XMLHttpRequest$ RewriteRule ^(messages.*) /other/$1 [R=301,NC,L] I want to redirect all AJAX/XMLHttpRequest requests from /messages to /...
Thomas Andersen's user avatar
0 votes
2 answers
2k views

Mod_rewrite rule to redirect from a specific path to another is completely ignored

I need to redirect http://1.2.3.4/foo to http://1.2.3.4/WebFOO. The rule that I've created looks like this in ApacheRoot\conf\httpd.conf: RewriteEngine On RewriteRule ^/?foo /WebFOO [R,L] However, ...
OddDev's user avatar
  • 111
0 votes
1 answer
296 views

mod_rewrites in nested .htaccess causing strange 404

I have an apache HTTP server with a directory structure as such: / ---- api/ ---- ---- index.php ---- ---- .htaccess ---- index.php ---- .htaccess /.htaccess: DirectorySlash Off RewriteEngine On ...
Hele's user avatar
  • 101
0 votes
1 answer
90 views

Accessing site via multiple virtual hosts with https

I have an apache server that sits in front of a JIRA Service Desk instance running on Windows Server 2012. We have 2 customer portals in JIRA and I need to set up Apache so that each customer portal ...
Wesley Smith's user avatar
0 votes
1 answer
615 views

mod rewrite not working after dist-upgrade debian 7 to 8

I needed to upgrade my Debian OS version on a server, from 7 to 8. So i did : aptitude update aptitude upgrade to have the latest wheezy packages, then change in /etc/apt/source.list (and other ...
Overdose's user avatar
  • 101
0 votes
1 answer
200 views

How to forward page to different file using mod_rewrite

I'm trying to user mod_rewrite to forward user from default index.html to default.php, I've tried using: Redirect 301 /index.html /default.php in /html/.htaccess but it adds default.php repeatedly ...
aSystemOverload's user avatar
0 votes
1 answer
676 views

Mod_rewrite: Redirect to url in query string

Apache server receives request in following format http://192.168.110.65/?http%3A%2F%2Fdev.virtualearth.net How do I have Apache generate a redirect to the query string using mod_rewrite http%3A%2F%...
Rama Arjun's user avatar
0 votes
1 answer
470 views

Apache mod_rewrite. Able to "failover" when files do not exist?

I'm trying to configure mod_rewrite to attempt to load/serve files in a specific order. I think the easiest way to describe what I'm trying to achieve is with an example. Let's say in my document ...
Michael's user avatar
0 votes
1 answer
240 views

RewriteRule changes URL only when it doesn't end with slash?

This simple rule in .htaccess handles languages at my website: RewriteRule "^(de|it|es|fr|en-us)(?:|/(.*))$" "$2?lang=$1" [NC,QSA] It works fine unless I miss slash at the end of URL. Than it ...
Wh1T3h4Ck5's user avatar
0 votes
1 answer
36 views

Rewrite for Proxying

I have 2 servers. example.com and proxy.example.com I would like proxying /server/(.)/banner/(.) to http://proxy.example.com/banners/banner_$2_$1.png I have prepared in example.com apache2 vhost ...
Dream's user avatar
  • 11
0 votes
1 answer
39 views

.htaccess configuration to mask site?

I own a domain on godaddy (rainychat.com) and i have an app on Openshift (rainychat-jgal.rhcloud.com) Currently i have a forwarding rule on godaddy so when a user goes to rainychat.com it is ...
user5869120's user avatar
0 votes
1 answer
256 views

mod_rewrite redirect and hide extension

I want to hide the .php extension from all files and my regex is not working properly, it is redirecting the following /path/to/script.php?param1=test.php -> /path/to/script?param1=test It is ...
Everydaypanos's user avatar
0 votes
1 answer
807 views

Apache RewriteRule with Proxy and Changing Content-Type

We are currently using mod_proxy to proxy to proxy to the correct destination with the following line: ProxyPass /my-path balancer://server/path/to/real/thing However, a third party is sending us ...
Xetius's user avatar
  • 396
0 votes
1 answer
207 views

Apache2 and proxy_balancer BalanceMember

I've got this Apache2 site configuration, allowing me to "run Apache as a proxy" of the localhost:8080 service. <VirtualHost *:80> ServerName foo.mydomain.com RedirectPermanent / https:/...
auino's user avatar
  • 143
0 votes
0 answers
92 views

RewriteCond fails on existing file

So, my .htaccess file starts with: Options -MultiViews RewriteEngine on RewriteBase / And I tried: RewriteCond %{REQUEST_FILENAME} -f or RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f or RewriteCond ...
user64675's user avatar
0 votes
1 answer
766 views

How to read specific character out of request header in apache http.config

We are trying to read specific character out of http request header to determine the type of URL it needs to be forwarded it. E.g., Http header - HTTP_ACCEPT=version.ver1+xml In Httpd.config, we ...
Sujit's user avatar
  • 1
0 votes
1 answer
97 views

Apache: Extracts parts of variables from rewrite rules in headers

I have a rewrite map associating pictures hash to the real path (to be kept secret) of the picture. With a single rewrite rule I can give back the picture with the hash as the url, that's fine. ...
user333088's user avatar
0 votes
0 answers
760 views

Fix ERR_TOO_MANY_REDIRECTS after adding trailing slash in URL

I have a Magento website hosted in a managed server where we need to use two .htaccess files, the first one is needed to redirect all request to a subfolder /current/src/ and is placed directly in ...
Proxium's user avatar
  • 111
0 votes
0 answers
1k views

Backreferencing a cookie value in rewriterule

I'm trying to backreference a cookie's value in a RewriteRule : # Trace rewrite rules log LogLevel alert rewrite:trace4 # Rewriting the URL, in the cookie's condition i've tried en alone, and en|fl|...
Ismail H's user avatar
  • 107
0 votes
0 answers
137 views

How to block referral source on apache with special characters?

I've been getting referral spam on my site. I've tried several options to block it, but it still hits it. I think it has to do with being special characters on the referral? This is the referral ...
smorhaim's user avatar
  • 229
0 votes
1 answer
2k views

mod_rewrite not working for apache alias

I have created a documentation wiki that i want to attach to my main site using an Alias for the virtual host. This allows me to access the wiki by going to website.com/documentation. I have ...
Dan Hastings's user avatar
0 votes
1 answer
1k views

Apache Mod Rewrite - exclude folder and subfolders, except for one subfolder

I have a Mod_Rewrite setup as follows: RewriteCond %{REQUEST_FILENAME} !^/www/live/site.name/app/public/(/forms/|/crm/) RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f ...
steve's user avatar
  • 153
0 votes
0 answers
460 views

mod_rewrite hide URL params

I have the following URL: www.mydomain.com/musician.php?musician=musicianname&id=idnumber I am using mod_rewrite to achieve this: www.mydomain.com/musician/musicianname/idnumber This is the rule ...
Gabriel Ferraz's user avatar
0 votes
1 answer
318 views

RewriteRule [E=let_me_in] and 'Require env let_me_in' don't work together

I have a problem similar to this: http://www.tek-tips.com/viewthread.cfm?qid=1144803 I'm trying to grant access, if specific RewriteRule triggered. Setting a var using [E] flag, but the var seems ...
basin's user avatar
  • 558
0 votes
2 answers
51 views

forbid cgi invocation by direct url, but allow via a RewriteRule

I want to allow anonymous client execute a script via a special URL, but not directly. Everything else should require auth. <Directory "/srv/http"> Require all granted </Directory> &...
basin's user avatar
  • 558
0 votes
1 answer
81 views

How is leading slashes handled in server and in client?

I am trying to create a RewriteRule, but it's unreliable and I can't figure out what is happening. Here's my rule: RewriteRule ^docs/(......)/$ index.php?docid=$1 [L] the problem is leading slashes, ...
Omar Saad's user avatar
  • 111
0 votes
1 answer
489 views

forward slash and mod_rewrite

This might be a stupid question but it took me days to even figure out what the problem was. I'm using mod_rewrite and passing values separated by forward slashes. The problem is that the forward ...
Simon Bradley's user avatar
0 votes
0 answers
194 views

Problems loading CSS. Error.log prints: "Request exceeded the limit of 10 internal redirects"

I have issues on my server. When I do changes to CSS file they are not showed until one day later or more. I have seen the following error in the apache error.log: [Thu Jul 16 08:48:49.193132 2015] [...
miganml's user avatar
  • 23
0 votes
2 answers
3k views

"deny all" for all files in a directory

My server is getting hit hard by bots, etc., looking for various files in /cgi-bin/, like search.cgi, YaBB.pl, gitweb.perl, perl, gitweb.pl, htsearch, and on and on. I want to deny all access (send a ...
markratledge's user avatar
0 votes
0 answers
74 views

Is there a way to redirect HTTP to HTTPS using mod_proxy_ajp or this could be done only at mod_rewrite side?

What is the easiest way to redirect http to https when mod_proxy_ajp is used? I have the configuration below for mod_proxy_ajp: ProxyPass /home ajp://localhost:8080/home ProxyPassReverse /home ajp://...
JonathanC's user avatar
0 votes
1 answer
70 views

mod_rewrite - detect a GET Request URL and render index.php

Sorry for the 1000000 topic on this, but I've been trying and searching for hours and couldn't find anything. Basically, I have already used mod_rewrite to allow someone to type in www.example.com/...
Luop90's user avatar
  • 1
0 votes
0 answers
299 views

Truncate URL's with Apache mod_rewrite

I am trying to strip incoming page requests to 25 characters after the year/month structure of the URL on my Wordpress server. Reason is, there are a number of external 404 links that I would like to ...
Kris's user avatar
  • 1
0 votes
0 answers
65 views

Apache2 keeps rewriting https even though rewrite rules are removed

I am running multiple virtual hosts on a local machine running Ubuntu 14.04 and Apache2. Let's assume that the project I am trying to access has the ServerName directive set to website.local When I ...
Pankrates's user avatar
  • 125
0 votes
0 answers
240 views

Use mod_rewrite & mod_jk to access different workers

I want to achieve the following: There is one DMZ-proxy over which we want to access multiple application-servers, represented by mod_jk workers. The web-context needs to be the same on all ...
Michael Niemand's user avatar
0 votes
1 answer
433 views

htaccess: get request domain for mobile redirect

We have a mobile site that is served using multiple domains. We want to redirect users who are using desktop user agents to our desktop sites while preserving the original domain the user used to ...
user avatar
0 votes
1 answer
657 views

mod_rewrite not acting as expected -- missing path info

I've just installed a fresh apache (Apache/2.4.7 - Ubuntu) and created and enabled a site with a Document Root of /var/www/html. With mod_rewrite enabled, I proceeded to create a simple .htaccess file ...
Chadananda's user avatar
0 votes
1 answer
76 views

apache allowoverride points to wrong location

I installed a Slim framework to create a API and located this under /opt/modul/www/api index.php slim/ so the index.php is my main API file. And I want to access this in the browser under ...
user1908375's user avatar
0 votes
0 answers
57 views

Apache mod_proxy redirect with absolute domain

I am using the example from apache to rewrite a url with proxy: RewriteRule ^widget/(.*)$ http://product.example.com/widget/$1 [P] I want to set a absolute domain for this: RewriteRule ^de....
Mutatos's user avatar
  • 111
0 votes
1 answer
68 views

Can I not setup multiple redirects using apache?

I have single web application on the server with multiple domain names (pittsburgh-app.com, philadelphia-app.com, etc). Now the domain names are changing to (new-pittsburgh-app.com, new-philly-app....
Rayhan Muktader's user avatar
0 votes
0 answers
296 views

How to rewrite request for subdirectories using apaches' mod_rewrite?

My document_root is /home/john/public_html. I need the URL example.com/subdir/index.php to be handled by the file /home/john/public_html/index.php. This is what I put in /home/john/public_html/....
GetFree's user avatar
  • 1,530
0 votes
0 answers
75 views

simple conditional mod_rewrite for redirecting wrong urls

I have an assignment to add storeId parameter to wrong urls. It should behave like this: If url has directorystore/a in it like www.example.com/store/a - the next directory in path has to be www....
JulioBordeaux's user avatar
0 votes
1 answer
1k views

Apache proxy to Glassfish - How to supress subfolder in URL?

I've got a single linux server running Apache/2.2.24 running both HTTP/HTTPS along with a Glassfish 3.1.2 server listening on port 8080. Glassfish runs a single deployed application which has ...
PeteJ's user avatar
  • 1

1
6
7
8 9 10