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

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 LocationStrategy http://host.tld/page, which obviously…
pop
  • 101
  • 2
0
votes
1 answer

Redirecting all requests to domain except for some folders

I try to redirect all requests from a domain to a subdomain, except for /mypath and all stuff below. Examples: example.com -> sub.example.com example.com/somestuff -> sub.example.com but example.com/my-path should not be redirected. Here's the…
tymik
  • 398
  • 2
  • 6
  • 16
0
votes
1 answer

Apache Rewrite rule conflict

I am working on a rewrite rule in Apache 2.4 in which any URL that ends with .pdf/ should add a query parameter and transform it to .pdf?q=pdf. Example: http://www.example.com/us/elections.pdf/ should transform to…
0
votes
1 answer

Adventures in Drupal multisite config with mod_rewrite and clean urls

The university where I work is planning to offer Drupal hosting to staff/faculty who want a Drupal site. We've set up Drupal multisite with clean urls and it's mostly working except for some weird redirects. If you have two sites where one is a…
moexu
0
votes
1 answer

Add www to domain but not for a specific domain

I've the following code in my .htaccess file: RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] The code above is for adding www to the domain if it does not have the www. But I have a domain like:…
Igor
  • 135
  • 7
0
votes
2 answers

How to redirect /services to /services/onetime?

Through htaccess file I am trying to redirect /services to /services/onetime but its redirecting me to /services/onetime/onetime/onetime/... What is the problem with the code and is there a way to do it? This is the code I have used: redirect 301…
Vikram
  • 167
  • 2
  • 10
0
votes
1 answer

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 redirection: / /#/ /#/admin /#/auth Otherwise, point…
jrance
  • 1
  • 2
0
votes
2 answers

Help with a mod-rewrite rule

How do I say, "if the file is in the /wp-content/* directory, serve it as long as it's .+\.(jpe?g|gif|png|js|css)$, otherwise throw a [F]orbidden." I can't seem to wrap my head around where to begin. I'm okay with regex, but my mod-rewrite skills…
Jeff
  • 1,416
  • 3
  • 28
  • 50
0
votes
1 answer

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/ and http://localhost:8080/foo/ And I want to be able…
Bill Comer
  • 101
  • 1
0
votes
1 answer

How can I find while rewrite rule in this htaccess file cause an internal server error?

I have an htaccess file that starts out like: RewriteEngine On RewriteBase / RewriteCond %{QUERY_STRING} where-can-i-find-information-about-homer-training RewriteRule ^(.*)$ …
rixter
  • 103
  • 3
0
votes
0 answers

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 ^(.*)$ /www.example.com/$1 [L] So, if a visitor goes…
J23
  • 113
  • 4
0
votes
0 answers

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 /other/messages The condition and rule above works for…
0
votes
1 answer

mod_rewrite to serve static file based on specific query string with mod_proxy

I would like to have a reverse proxy (apache httpd with mod_proxy) in front of an IIS hosting a SOAP Web Service. The problem I'm facing is that the SOAP clients ask the web server for the details about the web service by downloading the WSDL from…
MattBianco
  • 597
  • 1
  • 7
  • 23
0
votes
3 answers

how to disable trace & redirect to https at same time using mod_rewrite?

I have a RHEL4 server with apache 2.0.52. I want to disable trace method and redirect all http requests to https both at the same time in one virtualhost. I have done foll. RewriteEngine On RewriteCond %{REQUEST_METHOD} ^TRACE RewriteRule .* -…
amolkul
  • 111
  • 5
  • 9
0
votes
1 answer

htaccess rewrite rule, root url to index.php fake directory to different .php file

I've struggled with exactly what to search to find the answer to this question so I thought I would ask it instead. I am building a small CMS script with PHP and want to prettify my urls. I have no issue with sending root level requests to my…
Benjy
  • 1
  • 2