mod-rewrite

htaccess directory to file redirect problem

I’m trying to use the following .htaccess file RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^images/ RewriteRule (.*) view.php?picid=$1 [L] RewriteRule ^/user/(.*)$ /users.php?user=$1 I want two things to happen: Whenever someon...

Kohana, .htaccess, and $_GET

After uploading my Kohana project to my Godaddy server, I noticed my standard .htaccess file wasn't working sufficiently to provide the clean URLs. After some guidance, I ended up with the following rule: RewriteRule .* index.php?kohana_uri=$0 [PT,L] This got my nice-URLs working again, but today I find out that it may be breaking my ...

javascript taking # marker literally

Hi, I have some code on some of my links <a class="nav_bu" onclick="switchType('all'); return false;" href="#"> when I click on them, I get fowarded to mydomain.com/# (404 error..). How can I get the function activated, rather then the href link. P.S. I have mod_rewrite running, is this screwing things up? Here are the rules that e...

Web application deployment to limited user population

Hi all, I'm trying to determine the best way of deploying new versions of an established web application. In the past, I've done it a couple different ways but this time we're looking to do something a little different/better. We're using development/staging/production servers. After the development is done and the basic functionality...

htaccess rewrite rule not loading site content

I am struggling with .htaccess rewrite rules. Let's say I have this URL. localhost/site/index.php and I want to rewrite it as this URL localhost/site/tutorial I would use this RewriteRule Options +FollowSymLinks RewriteEngine on RewriteRule ^tutorial/(.*)$ /up/index.php The page works, but the CSS files don't load. Also, if I ...

mod_rewrite to different server

Hi - I've had a look through the many mod_rewrite examples, but I can't find out how to rewrite the URL so that a query to one domain gets redirected to the new domain, and has a specific URL parameter added. I need to achieve the following: a) change the server name b) change the path to incude the application name c) append URL para...

Apache ssl redirect using mod_rewrite

I want to do this: if they do https://example.com I want to redirect them to https://www.example.com (add the www.). I have tried oodles of things to no avail. Redirect https://example.com/&lt;anything&gt; to https://www.example.com/&lt;anything&gt; RewriteCond %{HTTP_HOST} ^example\.com [NC] RewriteCond %{SERVER_PORT} =443 RewriteRule ...

passing GET parameters that look like URI directories

I've seen a lot of URIs that look something like this: www.fakesite.net/stories/1234/man_invents_fire and I was wondering if the /1234/man_invents_fire part of the URI are actually directories or if they are GET parameters (or something else). I've noticed that a lot of times the /man_invents_fire segment is unnecessary (can be remove...

mod_rewrite: replace underscores with dashes

I'm revealing my embarrassing ignorance of REGEX-fu here, but: I currently have a website where a load of the articles' URLs are written as "article_name", whilst the newer ones are written as "article-name". I want to move all of them to using dashes, so is there a regular expression I could use to rewrite the older URLs to their newer...

Is there an easy, simple, lazy way to test rules against Apache's mod_rewrite?

Hi, I want to test the effects of my RewriteRules without going through all the trouble of setting up a vhost and a RewriteLog and throwing URLs at the browser (or curling them). But I don't just wanna test regular expressions. I want my URLs to actually go through Apache's mod_rewrite stack, and I want to see the response that would c...

How to use SetEnv with a URL parameter

I'm trying to implement language switching in .htaccess, and the only thing left now is to handle clients which don't support cookies. To do that, I must set prefer-language when the user clicks a link with a language parameter. RewriteEngine On RewriteBase / RewriteCond %{QUERY_STRING} (?:^|&)language=(en|fr|no) RewriteRule ^(.*)$ $1?...

switching my app from http to https

hello, i'm working on an extranet for my school, in php and mysql, running on apache2 and using friendly urls via mod_rewrite. I'm thinking that since there is potentially sensitive data involved, it would be better to work on an https url rather than http. The thing is: i have absolutely no experience in https. The pros, the cons and ...

Lighttpd mod_rewrite to Apache Mod_rewrite

Hello, I am looking for some help here. I am trying to convert lighttpd mod_rewrite to apache mod_rewrite Here it is. Lighttpd url.rewrite-once = ( "/torrent/([0-9A-F]{2,2})([0-9A-F]{2,2})([0-9A-F]{36,36}).*" => "/t3/$1/$2/$3.torrent", ) I look up multiply tutorials of apache's mod_rewrite but really no help. Here what I came up...

Problem with mod_rewrite rules in .htaccess file

This is my .htaccess file but it is not working. Not any URL is redirected. Help me. RewriteEngine on RewriteRule ^home index.php RewriteRule ^contactus index.php?file=c-contactus RewriteRule ^course_registration index.php?file=c-course_registration RewriteRule ^ncplhpage index.php?file=c-ncplhpage RewriteRule ^scplhpage index.php?file=...

Problem in image display using htaccess.

When I try to display image using image tag, there is problem to display image. For now images are in project/images/logo. The page where I am displaying image is in project/projectadmin/file.php. The image path is given as below http://localhost/project/images/logo/cat%5F149.jpg. When i remove htaccess, then no problem to display imag...

Can I use mod_rewrite to redirect to a URL with a zero-padded parameter?

I'm trying to use mod_rewrite to redirect URLs from a URL from an old host to a new one that uses a different URL format. The new host zero-pads the ID to six digits as follows: Old URL: http://www.example.com/script.cgi?page_id=123 Needs to redirect to: http://archive.example.com/000123/ This is what I have so far: RewriteCond %{...

Rewrite URLs to not include file extensions

Here's a recurring problem. There are similar questions on SO about this, but nothing quite answers my question. I've got a website and I want every page to be available at only one URL. It should work dynamically on all pages, not on a sinlge hard-coded filename. domain.tld/foo should redirect to domain.tld/foo/ domain.tld/foo.php sh...

mod_rewrite - redirect from one domain to another and preserve trailing values in url

Hi, I think this is a pretty straight forward question in mod_rewrite: I got one domain, which needs to redirect to another, but keep any value after last slash (/) in the first URL, over to the second. domain.com/4433 should transfer to domain.com/folder/?p=4333 Listed for clarity: From: domain.com/4433 To: domain.com/folder/?p=43...

nginx rewrite rule

HI, Given the following apache/mod_rewrite rule taken from .htaccess within minify directory on the server: RewriteRule ^([a-z]=.*) index.php?$1 [L,NE] what will be the nginx compatible equivalent of it? I have tried: rewrite ^/minify/([a-z]=.*) minify/index.php?$1 break; but that doesn't seem to work. Any ideas guys? ...

Hide index.php (or index.html) of an URL

When I type the address of my site in a browser (mysite.com), it redirects to mysite.com/index.php. Why not to index.html ? Because I changed it in the conf file in Apache 2.2 . Now I would like to hide the last "index.php" part. How do I do that ? Would it be different it was index.html than index.php ? Wouldn't be ugly if by lookin...