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
1 answer

apache2 rewrite configuration not working

I have a file www.example.org.conf that I want to redirect http to https. The problem is the file doesn't exactly work right. ServerName example.org ServerAlias www.example.org DocumentRoot…
0
votes
1 answer

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%2Fdev.virtualearth.net This is my…
0
votes
1 answer

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 root the following files/folders…
Michael
  • 1
  • 1
0
votes
1 answer

Apache htaccess redirect http/www to https/non-www

To redirect from - http://www.domain.com - http://domain.com - https://www.domain.com to https://domain.com im using the following (apache)htaccess: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$…
ratoli
  • 1
0
votes
1 answer

Is there a way of writing cleaner rewrite rules if you've a large number of redirects to implement

I recentley completed a project whereby I moved a pretty large website to a nice clean smaller website. What this meant was I had to account for a large number of pages that had been indexed by search engines and redirect them appropriately to a…
0
votes
1 answer

Getting RewriteCond directory flag to work without trailing slash

I'm trying to detect existing directories, supporting both with and without a trailing slash in the URL but without doing a redirect for missing slashes. Here are the rules: RewriteCond /home/user/public_html%{REQUEST_URI} -d RewriteRule ^…
Rory Fitzpatrick
  • 183
  • 1
  • 2
  • 9
0
votes
1 answer

apache hangs when tomcat fails

I have apache in front of Tomcat, using mod_rewrite and mod_proxy to relay requests while serving static content directly. The Tomcat server can get bogged down and stop responding, or just plain crash. My problem is that in those cases it takes the…
itsadok
  • 1,869
  • 5
  • 22
  • 33
0
votes
1 answer

mod_rewrite a subdomain URL to another website

I need to create a redirect so that the URL domain1.mysite.com/user/register goes to differentsite.com/user/register That's the only URL I need to redirect (the rest of domain1.mysite.com stays where it is). There is only one htaccess file for the…
Eileen
  • 115
  • 2
0
votes
1 answer

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 changes URL in browser's address bar which is not what I…
Wh1T3h4Ck5
  • 101
  • 4
0
votes
1 answer

apache2 rewrite rule: delete any path from URL

I'm going crazy with a Rewrite Rule on Apache. Basically what I want to achieve is to rewrite any url like: http[s]://www.example.com/something to https://www.example.com I have a VHost on apache like the following: ServerName…
cloud81
  • 163
  • 1
  • 2
  • 8
0
votes
2 answers

apache rewrite mod enabled but getting errors

Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration Invalid command 'RewriteCond', perhaps misspelled or defined by a module not included in the server configuration i ran a2enmod…
hwohgo
0
votes
1 answer

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 settings the following rule RewriteRule …
Dream
  • 11
  • 1
0
votes
1 answer

What does this RewriteRule do?

I'm trying to migrate rewrite rules from apache to nginx. Can anybody explain what RewriteRule ^api/.$ - [L] does?
andrekeller
  • 499
  • 2
  • 5
0
votes
1 answer

.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 redirected to rainychat-jgal.rhcloud.com So far so good.…
0
votes
1 answer

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 removing the ".php" from both the %{REQUEST_URI} and the…