.htaccess

htaccess Redirect Scenario, featuring WordPress

I'm no good at anything that requires regular expressions - this includes redirects. I need to redirect all subpages to a particular subpage. Everything I've tried either fails or causes an infinite redirect loop. Example: Say I want everything under the domain to redirect to www.test.com/fubar (but obviously not /fubar) This seems li...

rewrite urls with GET reqs

Hello, how do I configure my .htaccess rewrite rules to accomodate GET requests? Currently, /manager/page goes to: ?dept=manager&n=page however, some pages have additional GET reqs, and so this rule doesn't work: RewriteRule ^([A-Za-z]+)/([A-Za-z]+)$ index.php?dept=$1&n=$2 [QSA] I would need: ?dept=manager&n=page&id&etc=etc to go to:...

Using relative URLs with mod_rewrite

Environment: Apache 2 shipped with Mac OS X Leopard; with no big changes in the default httpd.conf. I am setting up some rewrites through my .htaccess but I am not able to use target paths relative to the current directory. # URL: http://localhost/~davis/rewrite/.htaccess # File: /Users/davis/Sites/rewrite/.htaccess RewriteRule go.php...

How to redirect request coming from a domain to a subdirectory invisibly?

Hi, I am trying to redirect all requests coming from example.com to a subdirectory. The code below accomplishes this but I cannot make the subdirectory invisible. (The subdirectory contains a Drupal instance with its own/htaccess file. Could that be the problem?) RewriteCond %{HTTP_HOST} ^example.com$ [NC] RewriteRule ^(.*)$ http...

PHP $_SERVER['DOCUMENT_ROOT'] and htaccess?

I know that you cannot simply set DocumentRoot in htaccess but it's all I have access to. Is there a work around? How should I proceed? Or is this the wrong configuration for a setup like this? I have a dev server where: www.foo.com is mapped to /usr/www/users/foo. I then have www.foo.com/peter => /usr/www/users/foo/peter www.foo...

How can I make my website redirect to another based on a cookie with .htaccess?

I'm trying to do this with .htaccess. So what I did was set a cookie named "domain" with the website I'm redirecting to. In my .htaccess file I have this RewriteEngine on RewriteCond %{HTTP_COOKIE} domain=([^;]+) [NC] RewriteRule ^(.*)$ %1/$1 [L] I got that code from a Google search. It's supposed to reditect http://mywebsite.com/some...

htaccess 301 Redirection for Multiple Files

I'm wondering if multiple entries on htaccess will work for 301 redirects. The problem I see is that old site files have 'html' extension and are named named differently so a simple global redirect won't work, it has to be one rule per file name. This sites receives 1000 visits daily so need to be careful not to penalize search engine....

Redirecting root only via .htaccess with other rules in place

I have an installation of YOURLS that redirects generated addresses to a different domain, however the root does not redirect. How can I set a rule that cooperates with the existing rules to achieve this? Here's the .htaccess file as it stands: # BEGIN ShortURL RewriteEngine On #RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteC...

Use HTTP Auth only if accessing a specific domain

I've got several sites: example.com, example1.com, and example2.com. All of them point to my server's /public_html folder, which is my Apache root folder. What do I need to add to my .htaccess file to use http authentication only if the user is coming from example2.com? example.com and example1.com should NOT use authentication. I k...

CakePHP and .htaccess in shared hosting environment

Greetings! I have CakePHP based app on shared hosting I wonder if there's a way to clean up the url through .htaccess. What bugs me is that I have to have index.php in it or I get a 404: project.com/index.php/controller/method Initially I was getting a 404 error no matter what and my host admin ended up setting RewriteEngine off and t...

Rewrite both domain and path

I want to redirect one specific url like: www.example.com/test/ex.gif to static.example.com/ex.gif How can i do this in .htaccess? ...

Domain to point to a single page

Hi, I'm trying to point a domain name to a single page, and keep the domain the same (no redirect). So if a user types: www.domain1.com.au --> original site is shown If a user types: www.domain2.com.au --> they are shown www.domain1.com.au/second.php, but the URL still says www.domain2.com.au. Can this be done using .htaccess? Snippe...

Some Problem with htaccess!

How can I redirect my users from example.com / or www.example.com to new.example.com but I dont want to redirect some specific urls like: www.example.com/test.php api.example.com/testo.php www.example.com/forum/index.php I did: RewriteEngine on RewriteCond %{HTTP_HOST} ^example.com$ [OR] RewriteCond %{HTTP_HOST} ^www.example.com$ Re...

How can I make new site visitors see the splash page through mod_rewrite?

Basically, my client wants to make new visitors enter the site I'm working on through the splash page. Unfortunately, Google indexed the home page. So no one ever actually sees the splash page. Is there a way that I can make a .htaccess file create a cookie in the viewers browser that says "I'm not new" (or maybe showsplash=false). Then ...

.htaccess multi domain using

Hello all, I have problem. I want to load defined folders into my website from same system, now I need to know how I can get a folder from a domain if I type "domain.dk" its load "theme/domain.dk/javascript/ and if I type "domain.com" its load "theme/domain.com/javascript/" folder to use. RewriteRule ^Javascript?$ /theme/{HTTP_HOST...

.htaccess RewriteRule apache: how to rewrite based on URL parameter?

I have URLs with lots of parameters, here is an example that looks like this: http://www.mysite.com/profile?reset=1&force=1&gid=9&custom%5F18=BS+Forestry%2C+University+of+Kentucky I would like to do a RewriteRule that redirects any request containing the string: &custom To a static HTML page such as: http://www.mysit...

.htaccess subdomain.(.*) go to url

i have a problem, i dont know how i can make this code to work. i need to know all subdomains ( scadmin.* ) its go to folder /admin/theme/(domain whitout subdomain)/ sombardy know what i can doe here? tanks a lot for all respons ...

mod_rewrite redirect to URL with propietary protocol

I'm using Apache 2.2 with mod_rewrite. Is there a way to force mod_rewrite to rewrite the entire URL, including protocol? I know it will automatically rewrite the whole URL if the redirect contains http:// at the beginning but I'm trying to redirect to a URL that uses a proprietary protocol: fcp:// When I add it in as the redirect it j...

file upload security, htaccess, and changing extensions

Hello, all. I'm pretty new to web development, so please be gentle. Apologies if I'm posting a topic that's already been discussed; I searched but couldn't find quite what I was looking for in another thread. Background: I have a site that allows file uploads, but once uploaded, they won't need to be viewed by anyone but me. I've ...

Hide folders with .htaccess

Is it possible to hide the folders in my root folder? Just in case my index.php would disappear you know? Could I also show 404 error not found if someone requests them? ...