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
2 answers

301 Redirect and query strings

I am looking to create a 301 redirect based purely on a query string see b OLD URL: olddomain.com/?pc=/product/9999 New URL: newurl.php?var=yup My normal way of doing this would be redirect 301 pc=/product/9999 newurl.php?var=yup But this time I…
icelizard
  • 732
  • 3
  • 10
  • 20
1
vote
1 answer

mod_rewrite and % character

I need to rewrite a URL that contains one or more strings of characters incling a % character (for instance %123) into another string of characters including a % character (for instance %234). I am able to do this using the special THE_REQUEST…
user37839
1
vote
2 answers

Redirecting requests that would result in an HTTP 400 (Bad Request) error (Apache 2.2)

Due to a security vulnerability in Wordpress, a bunch of my posts got renamed to something like: http://**MYSITE**/2008/08/21/**POSTNAME**/%&%28%7B$%7Beval%28base64_decode%28$_SERVER%5BHTTP_EXECCODE%5D%29%29%7D%7D%7C.+%29&%/ I've since fixed the…
inxilpro
  • 185
  • 2
  • 6
1
vote
1 answer

(Invisibly) Rewriting from folder to subdomain

A site currently exists at www.foo.com. I need to setup a (wordpress) blog at www.foo.com/blog, but on a separate server (with a domain something like blog.bar.com). The site visitors should only see the www.foo.com/blog URL. So: User sees …
anu
  • 544
  • 1
  • 5
  • 10
1
vote
1 answer

mod_rewrite replace / with _

Sure I'm just missing something obvious here, but I have this: RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^(.*)/(.*)$ $1_$2 [N] RewriteRule ^(.*)$ $1.php [QSA,L] Which I would like to rewrite /shop/basket to…
Jack Sleight
  • 211
  • 2
  • 8
1
vote
1 answer

Apache RewriteRule with Querystring

I've got a rewrite like this: RewriteRule /products.php?id=123&t=12345 /product/New-Product-Name If I turn on RewriteLogging, and turn the level up, I get the following: applying pattern '/products.php?id=123&t=12345' to uri '/products.php' Why is…
Glen Solsberry
  • 1,536
  • 5
  • 28
  • 38
1
vote
1 answer

passing URL vars to a wordpress page and pretty-fying it with .htaccess

I have wordpress installed in a directory called welcome, and /welcome/samples is a "page" (created via Wordpress). It's has a php template waiting for a $_REQUEST['category'] When a user goes to /welcome/samples/fun, I want to have "fun" passed to…
Jonah
  • 123
  • 1
  • 3
1
vote
2 answers

Is it possible to add a random variable to the querystring using mod-rewrite?

We're having a very odd problem with a proxy that a client uses. In short, their proxy is caching information that it should not be caching. We have the appropriate information in the header that tells the proxy server not to cache AND it's over…
Ian P
  • 123
  • 7
1
vote
2 answers

.htaccess to redirect any URL from a domain to a fixed URL on another domain

Anyone can help me out with an .htaccess I'm trying to create? I want to redirect foo.com to foo.ca. Any URL from foo.com (with or without www and under http or https) will all be redirected to www.foo.ca. Some examples: http://www.foo.com/ -->…
AlexV
  • 179
  • 1
  • 2
  • 16
1
vote
1 answer

Redirecting to a diferent exe for download based on user agent

I own a Linux-Apache site where I host exe files for download. Now, when a user clicks this link to my site (published on another site): http://mysite.com/downloads/file.exe I need to dynamically check their user agent and redirect them to…
Ra.
  • 217
  • 5
  • 11
1
vote
1 answer

Apache AliasMatch with Multiple Subdomains

I have the following virtual hosts: ServerName article.example.com AliasMatch "^/(.*)" "/var/www/html/article.php" ServerName company.example.com AliasMatch "^/(.*)"…
Maciek Semik
  • 139
  • 6
1
vote
1 answer

How to make multiple changes to REQUEST_URI at once?

I'm dealing with requests from a proprietary client, that sometimes uses back- rather than forward-slashes: GET /path\to\the\file.txt, and I'd like to straighten them all out. mod_rewrite can replace one at a time: RewriteRule ^(.*)\\+(.*) $1/$2…
Mikhail T.
  • 2,338
  • 1
  • 24
  • 55
1
vote
2 answers

how to block attacks with rewriterule?

getting a bunch of bogus requests hitting my server. would like to block any requests that include http:// in it. example: domain.com/forum/function/component.php=http://bogusdomain.gov.ve/images/foo.txt I thought RewriteRule ^(.*=http://) - [F]…
jimg
  • 262
  • 4
  • 15
1
vote
1 answer

htaccess redirects with special characters on an specific url not working

I need some help creating a redirect, I'm trying to replace all - to +, but both are special characters and also want to do it only when the URL contains ?s=. This is an…
1
vote
1 answer

Edit .htaccess file to make file accessible

I was trying to make a WordPress plugin work, when I found, after hours of debugging, trial, errors and praying ancient Greek gods, that the plugin did not work because it was impossible for the server to reach a particular file. The website is…