.htaccess

How do I redirect URLS that begin with /test/ to a separate script?

I have an existing htaccess that works fine: RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule (.*) /default.php DirectoryIndex index.php /default.php I wish to modify this so that all urls that start with /test/ go to /test/default.php. Example: http://www.x.com/hello.php -- > http:/...

Redirect 'myapp.com' to 'www.myapp.com' in rails without using htaccess?

Using Morph Labs' Appspace to deploy a site means no automated way to redirect 'myapp.com' to 'www.myapp.com' (and no access to .htacess). Is there an in-rails way to do this? Would I need a plugin like subdomain-fu? More specifically, I'm trying to do something like: 'myapp.com' => 'www.myapp.com' 'myapp.com/session/new' => 'www.mya...

Rewrite rules - going outside the docroot.

Assuming the following directory structure, htdocs/ images/ css/ .htaccess system/ index.php ... I would like to route all incoming requests through that php script. I have been trying some rewrite rules within the htaccess, but I can't seem to be able to route to files that are outside the document root. I couldn't find a r...

Htaccess Two different redirects.

I have an existing htaccess that works fine: RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule (.*) /default.php DirectoryIndex index.php /default.php I wish to modify this so that all urls that start with /test/ go to /test/default.php, while keeping all other URLs with the existing /...

Redirect joomla url's to wordpress

Hi. I moved an ex-site based on joomla to wordpress. Import worked fine but the problem is that the old links don't work anymore. Because there is only 50 or so articles, i thought will be a good idea to put a rule for each post (in .htaccess). Well... Not always things are like you want, so redirects dont work at all :( Old joomla lin...

Using mod_rewrite in .htaccess in both website root and a subdirectory

My dilema: In .htaccess in my website's root: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] In .htaccess in the subdirectory /foo RewriteEngine On RewriteRule ^page1\.html$ /foo/page2.html [R=301] In the first, I'm trying to ensure all requests include the...

Get PHP session vars in .htacces

Is it possible to read the data in the php $_SESSION array in the .htaccess file in Apache? So say I have the following: $_SESSION['foo'] = 'bar'; could I then in .htaccess do something like: RewriteRule bla.png folder/{the php session var foo}/file.png Is that possible? I already have a working workaround but if this is possible ...

automatic htaccess login - multiple protected dirs accessed from one login

I am trying to make a php login page that allows users to access multiple .htaccess protected pages (on apache server). So a user would enter a password in a form on page 1 and depending on which login they provided, they would be sent to one directory or another, but I want the login to happen automatically to the subsequent pages (log...

.htaccess - Is it possible to redirect post data?

Hi Stackers I have a website where all requests are redirected silently (via .htaccess) to index.php and then PHP is used to show the correct page (by traversing the REQUEST_URI). I was wondering if it's possible to submit POST data to a fake address too? I've currently got my form like so <form action="/whatplant/send-mail" method="...

How to color highlight .htaccess files in Eclipse

I spend some time editing configurations in .htaccess files across several projects in Eclipse. How would I go about telling Eclipse to auto color this file in a similar fashion as shell scripts or HTML? ...

.htaccess Rewrite Rules for subdomain

I use codeigniter as my main install on the main domain. I have created a subdomain and a folder called live e.g. live.domain.com maps to public/live . However in public I use codeigniter. I now have the dynamic codeigniter url: http://domain.com/api/ which I want to map to my subdomain: https://live.domain.com So going to: https...

.htaccess redirect with fragment

I need to issue a redirect, using .htaccess, to a URL with a fragment (also known as an anchor), but it's automatically escaping the #. At the moment I want a hard-coded fragment, but for the sake of others if you know how to take it from the URL too that would be good. Ideally I should be able to use QSA as well. For example: http:/...

Javascript compression via .htaccess?

I'm using Apache. I'm auto gzipping my HTML & CSS files on the fly using the following directive in my .htaccess file. # Enable ETag FileETag MTime Size # Set expiration header ExpiresActive on ExpiresDefault "access plus 1 year" ExpiresByType image/gif A2592000 ExpiresByType image/png A2592000 ExpiresByType image/jpeg A2592000 Expir...

.htaccess - Rule being ignored

Hello I use this line in my .htaccess file to automatically add a trailing slash if not present rewriteRule ^(([a-z0-9\-]+/)*[a-z0-9\-]+)$ /$1/ [NC,R=301] This works fine, until I use these lines to redirect all requests to not files or dirs to index.php RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f Rewrite...

Conditional .htaccess RewriteRule parameter

I have quite a few RewriteRules in my .htaccess that looks like this RewriteRule ^something/(\d+)/start /index.php?ix=$1 RewriteRule ^embed/something/(\d+)/start /index.php?ix=$1&fEmbed=1 The only difference between these two is the leading "embed/", so I was thinking it would be beneficial to combine these into a single Rewrite...

.htaccess URL is being cut at a space (I'm using Codeigniter)

I've used the following code to map https://live.example.com on to http://example.com/api Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTPS} =on RewriteCond %{HTTP_HOST} ^live\.example\.com [NC] RewriteRule (.+)$ "http://example.com/api/$1" [L,P] The following url: https://live.example.com/userlinks/xml/John%20James/MvP...

.htaccess rewritecond rewrite case level 2 folder=info

I wanted to set .htaccess to rewrite: example.com/bla/info/ to example.com/info/index.php?q=bla + example.com/bla/info/txt/ to example.com/info/index.php?q=bla&t=txt I wanted the browser still to display: example.com/bla/info/txt/ I didnt want rewrite in othe level 2 rewrites. like: example.com/bla/xxx/ or example.com/ccc/zzz/aaa/ b...

"RewriteRule ^([^/]+) index.php?id=$1" posts "index" instead entered text

If I do it by typing /?id=some_text in url then index.php script works as it shuld but if I do /some_text then index.php always receives id to have value "index". At first I had RewriteRule ^([^/]+) ?id=$1 but that returned "Internal Server Error" instead web page, then I changed it to RewriteRule ^([a-z]+) index.php?id=$1 and I stoped ...

public directory for .htaccess

I have a dispatcher function in index.php so URLs like: /blog/show go to /index.php/blog/show <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] </IfModule> How can I modify this so that I can dump all of my stat...

How can I redirect requests to specific files above the site root?

I'm starting up a new web-site, and I'm having difficulties enforcing my desired file/folder organization: For argument's sake, let's say that my website will be hosted at: http://mywebsite.com/ I'd like (have set up) Apache's Virtual Host to map http://mywebsite.com/ to the /fileserver/mywebsite_com/www folder. The problem arises whe...