.htaccess

Rewriting URL on dreamhost

I am trying to rewrite a URL for a Dreamhost served website. I want to do the following: Goal: Rewrite only URLs that start with an x. This: http:// domain.com/x23 Should become: http:// domain.com/index.php/lookup/code/x23 I tried this: RewriteEngine On RewriteRule ^(x[0-9a-z])$ index.php/lookup/code/$0 [L] but ...

.htaccess Why access to a file is forbidden on localhost?

I want to allow access to a file (secret.txt) only from my ip. Below is the .htaccess I'm using. It works great at my provider's server. However, at my localhost this .htaccess does not allow me to access the file. <Files "secret.txt"> order deny,allow deny from all allow from 1.2.3.4 </Files> Where my external ip is "1.2....

.htaccess: Transparently adding a name to the request

I've read this tutorial about how to modify your .htaccess in order to server many web2py applications but it doesn't seem to work. Here is my .htaccess RewriteEngine On RewriteRule ^dispatch\.fcgi/ - [L] RewriteRule ^(.*)$ dispatch.fcgi/$1 [L] RewriteCond %{HTTP_HOST} =www.moublemouble.com [NC, OR] RewriteCond %{HTTP_HOST} =moublemou...

Redirect subdomain to folder

Here's what I'm trying to do. When you type m.example.com I want users to be redirected to example.com/m/ but I would like the url in the address bar to remain m.example.com if possible. ...

How do I stop .htaccess Rewrite redirecting into the html folder?

I'm hosting on MediaTemple. I would like www.rhapsodicmusic.com to redirect to www.rhapsodicmusic.co.uk so that www.rhapsodicmusic.com/anypageordirectory will go to www.rhapsodicmusic.co.uk/anypageordirectory. I have the following code in my .htaccess RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^([^.:]+\.)*rhapsodicmusic\...

ColdFusion links redirection to Joomla

I need to keep my old coldfusion links in my new joolma site. I need to add a redirect mechanism in joomla like All urls like /search/commission.cfm?commID=456?t=2 should redirect to /sale?id=456 How can i do this? ...

Is this mod_rewrite rule correct?

Are these url rewrite rules and conditions correct? RewriteEngine On RewriteCond %{HTTP_HOST} ^example\.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] Basically, URL needs to be rewritten from non-www to www. Thanks ...

How to remove extension and force trailing slash with .htaccess

I managed to solve this problem by the following code: RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+.php RewriteRule (.*).php$ /$1/ [L,R=301] RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*)/$ $1.php [L] RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule .*[^/]$ $0/ [L,R=301] In other words, no...

How can I group all of my .htaccess rewriterules together more coherently?

Hi all, I am running a site that uses the following URL format for the archives style page: domain.com/view/ domain.com/view/page-2/ domain.com/view/by-name/ domain.com/view/by-name/page-2/ domain.com/view/by-price/ domain.com/view/by-price/page-2/ All these pages are powered by view.php so I have the following .htaccess file: rewr...

What is the best method to hide a file on a server?

I am going to make an image hosting system in PHP. I wondered how I should hide my images from users so they can only be accessed through a special url. I need to discuss all techniques that include htaccess. ...

301 Redirect. Need help. Having a hard time.

I'm trying to use mod_rewrite to redirect URLs and can't get anything to work. Here is what I'm hoping to do: Old URL: http://www.example.com/asp.pl?%5Fpuri=astore.amazon.com%2Fthegi02-20%2Fdetail%2FB0001L0DFA%2Fassid Needs to redirect to: www.example.com Anyone know of any way to do that? ...

Removing a folder from the URL using Apache mod_rewrite

How do you remove a folder from the URL? I have a Drupal installation in a folder and I would like to remove that subfolder from the URL. So instead of: www.example.com/subfolder/* I would like the url to be: www.example.com/* thanks ...

404 error for mod_rewrite using SSL and MAMP

I am building an app in Zend Framework at the moment and testing it all locally. I have Mamp Pro as my web server and I have a self-signed SSL which all seems to work. My problem comes when I try to do mod_rewrite - I just get 404 pages. The way I have things set up (which may not be the best way...) In Mamp I have 2 virtualhosts set...

htaccess redirect all html files

Can someone write me a rule that will redirect all requests for http://www.example.com/some_page.html to http://www.example.com/some_page/ Thank you!! ...

.htaccess rewrite rule

Hi, How do I write a rewrite rule for the following condition. I have my directory setup as /root/projectname/trunk/www/ I've setup site.local in hosts file to point to /root/ How do I make this request http://site.local/projectname to grab data from /root/project_name/trunk/www/ instead of from /root/projectname/ ? Right now I ...

.htaccess redirect www to non-www with SSL/HTTPS

I've got several domains operating under a single .htaccess file, each secured via SSL. I need to force https on every domain while also ensuring www's redirect to non-www's. Here's what I'm using which doesn't work: RewriteCond %{HTTP_HOST} ^www.%{HTTP_HOST} RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI}/$1 [R=301,L] Example: h...

Attempting an advanced htaccess rewrite trick, having difficulties

Hey guys, here's what I'm attempting: I'd like to make it so I can turn all url variables and values into folders, all with one rule. I was expecting to find some way to do this: www.example.com/var1/val1/var2/val2/varN/valN In an ideal world I could get rewrite to this: www.example.com/index.php?var1=val1&var2=val2&varN=valN...

mod_rewrite : only forward parameter that starts with number 4

I'm trying to modify the following rewrite conditions so that only strings that begin with the number 4 are redirected to the process.php page as a variable: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)$ /process.php?variable=$1 [L] So the following http://www.domain.com/4shopping wil...

Preventing access to files if a user types the full url on the address bar

Hi. i have a website, some folders on the websites contains images and files like .pdf , .doc and .docx . the user can easly just type the address in the url to get the file or display the photo http://site/folder1/img/pic1.jpg then boom.. he can see the image or just download the file my question is: how to prevent this kind of acti...

mod_rewrite : if / else type RewriteRule

The following rewrite passes a string starting with the number 4 as a variable to process.php : RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(4[^/]*)$ /process.php?variable=$1 [L] So this http://www.domain.com/4shopping is mapped to http://www.domain.com/process.php?variable=4shopping But...