.htaccess

mod_rewrite on domain root

I am trying to find the correct mod_rewrite code for the following case: domain.de => www.domain.com/de/ domain.de/... => www.domain.com/... www.domain.de => www.domain.com/de/ www.domain.de/... => www.domain.com/... domain.com => www.domain.com/en/ domain.com/... => www.domain.com/... www.domain.com => www.domain.com/en/ www.domain.co...

Mod_rewrite: How do I omit subdomains from rules?

Complete Apache newbie here. I'm trying to get my main URL to redirect to the www. Here's the code I'm using: RewriteCond %{HTTP_HOST} !^www\.domain\.com RewriteRule ^(.*)$ http://www.domain.com/$1 [R=permanent,L] The problem is, this has wrecked my subdomains. sub.domain.com goes to www.sub.domain.com, which doesn't work. So what d...

How do I append a / (forward slash) to a URL?

I am working on an Expression Engine site and the URLs end as follows: http://www.mydomain.com/education/new-courses I need to be able append a forward slash after just this one link, so that it looks like this: http://www.mydomain.com/education/new-courses/ I am looking for an appropriate ReWrite rule that would add the necessary ...

How to setup PHP to be a "pipe" for downloads from another location?

I'm wanting to setup a php script and host it on my server that will let me download files from other locations, but making it look like it's coming from my server. Maybe using curl or htacess. Also I was hoping that there would be a way to get around having my server deal with the bandwidth. Does that make sense? Is this doable? --...

Apache Rewrite Rule Regex Problem

So I have an Apache .htaccess file that contains this: RewriteEngine On RewriteRule ^/(javascript/.*)$ /$1 [L] RewriteRule ^/(styles/.*)$ /$1 [L] RewriteRule ^.*$ /index.php Unfortunately, the last line's coughing up a 500 error on the server that we've moved the code to. It works fine on my machine, Ubuntu 9.10 running Apache 2.2.12,...

Using RewriteRule in .htaccess for POST request

I am attempting to lock down a page to only accept POST requests. as part of an RESTful API. I have the following, but it doesn't seem to work. Any help would be appreciated. RewriteCond %{REQUEST_METHOD} POST RewriteRule ^api/(call1|call2|call3)/?/ http://www.example.com/api/rest_services.php?_call=$1 [L] ...

Controlling image bandwidth issues on a community site

Hello. I am working on a community photo sharing site, and I need some way of controlling the bandwidth. For example I would like to set a maximum bandwidth allowed, which can be image size x the number of times the image was viewed. Similar to what a site like photobucket does (when they replace an image with a bandwidth exceeded image)...

htaccess 301 redirect rule

Hi looking for help making a 301 redirect for: www.domain.com/word/* to www.domain.com/* Thanks. ...

Under Construction page For Website Without Redirect

Hi! I wanted to know if there is some way to change something simple, such as a htaccess file, a js file, or a php file, and then all of the webpages on my site will show an under construction page. I do not really care all that much if the user has to be redirected, but I want the origonal url of the page to be displayed in the address ...

htaccess conditional statements based on server name/path

Is it possible to write some conditional "if" statements in htaccess based on the server name/path? I know I can use <IfModule> but that doesn't solve the problem when the development and production server are identical. thanks ...

What does this Rewrite rule mean?

Im installing phpancake, there is a folder there shema like this application/ install/ library/ public/ sql_schema/ install.html install.php What does this rule mean? RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRu...

Combining multiple htaccess rewrite rules into one

First, let me say this: I suck at regex and htaccess. I'm trying to make a rule that will properly parse url segments into variables. So far I have this: RewriteRule ^([^/]+)/?$ index.php?query[]=$1 [QSA,L] RewriteRule ^([^/]+)/([^/]+)/?$ index.php?query[]=$1&query[]=$2 [QSA,L] RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?query[]=$...

Need help with Apache's mod_rewrite to fetch file based on url

So say I have a url being requested: sub.domain/file.bin and I wanted this file to be fetched: domain/hosted/sub/file.bin How would I structure the rewrite directives? I've been working on this for days, and it just gives me a headache... The subdomains are numerous and are added and removed often, so I'm trying to find a solution ...

htaccess rule is passing innecesary variable

This is the file tree: /problem/ /problem/index.php index.php category.php somefile.php I have this 2 rules in the .htaccess that is sitting in the / RewriteRule ^somedir$ /somefile.php [L] RewriteRule ^([a-z-]+)$ /category.php?cat=$1 [QSA,L] So... http://domain.com/somedir = OK http://domain.com/ = OK http://domain.com/problem/...

Apache / mod_rewrite / Periods messing with pattern

First question, here goes nothing... I'm trying to add a new entry to my .htaccess file (Apache server) with the hopes of translating this URL: http://platform.localhost/category.all into this URL: http://platform.localhost/index.php?page=category.all The RewriteRule that I'm currently using is this: RewriteRule ^([^/\.]+)\/?$ in...

PHP: how to serve right content-type (depending on file extension?)?

I'm using the scripts below to gzip some CSS and JS files. It works nice - except for serving JS files with the wrong content-type (and not the appropriate application/x-javascript). How could I improve the PHP code in order to serve the right content-type? Thanks! .htaccess: AddHandler application/x-httpd-php .css .js php_value auto_p...

.htaccess 301 redirect for all https to http EXCEPT ONE PAGE

Here is the code I have currently in my .htaccess file: Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] RewriteEngine On RewriteCond %{HTTPS} on RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] I know jack about rew...

Help translating .htaccess to web.config url rewrite

What would this rewrite rule from .htaccess translate to IIS7 web.config? RewriteRule .* index.php/$0 [PT,L] ...

Is there someway to change the content of a page with the htaccess file?

Hi! I just wanted to know if there is someway to use the htaccess file to chnage the content of a page(s). Maybe something sort of like the redirect, but instead of sending the user to another page, it would just change the content of the whole page. Thank you for any and all help! ...

.htaccess rewrite with REST style URL 500 error

Hi All, I'm trying to implement a REST-style URL with a mod-rewrite turned on in .htaccess. There's a bit of a kicker which is that I'm developing in a test environment (new cpanel account). Here's the .htaccess: RewriteEngine on #REMOVE THIS LINE ON SITE LAUNCH! RewriteBase /~myNewAccount/ #Hide .php extensions for cleaner URLS Rew...