mod-rewrite

mod_rewrite 'add path info postfix:'

Why is my mod_rewrite doing this? add path info postfix: /home/mobelluk/public_html/about.php -> /home/mobelluk/public_html/about.php/ which results in an unwanted trailing slash on EVERYTHING. I have disabled all my .htaccess rules so they're out of the equation. ...

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...

mod_rewrite rules and content negotiation

I am relatively new to mod_rewrite, but have a site which I would like to have "pretty urls." Similarly to SO :). I am attempting to have things like: "http://www.whatever.com/search/test" get rewritten to "http://www.whatever.com/search.php?q=test" and have had some limited success. I believe that content negotiation is getting in my w...

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...

mod_rewrite, .htaccess connecting to mysql database

I would like mod_rewrite in an .htaccess file to link to a mysql database to provide me with mapping information. Specifically, I am using a single code base to host multiple sites so..if a user requests an image, for example: http://www.example.com/images/car.jpg this is going to hit my server and many other sites will also be hitting...

After a RewriteRule to a PHP script, do an internal redirect from within the PHP

Hello, I have some mod_rewrite rewrites that correctly redirect the URLs to a script. From within the script, I want to go to a different file without causing another request/changing the URL. I have experimented with Location and meta refreshes but they are not as smooth as desired. Is there a way to change to the script or even retur...

apache resolving urls before looking in .htaccess

I have a rewrite rule of the following form: RewriteRule ^foo/([a-zA-Z0-9]+)$ foo.php?arg=$1 [qsa,nc] It takes urls of the form /foo/bar and changes them to /foo.php?arg=bar It works properly locally, and it works on my old host but I moved to a new host (running ubuntu) and it behaves differently. On the new host apache notices that...

How to encode special characters using mod_rewrite & Apache?

I would like to have pretty URLs for my tagging system along with all the special characters: +,&,#,%, and =. Is there a way to do this with mod_rewrite without having to double encode the links?' I notice that delicious.com and stackoverflow seem to be able to handle singly encoded special characters. What's the magic forumla? Here'...

RegEx match replace help

I am trying to do a regex match and replace for an .htaccess file but I can't quite figure out the replace bit. I think I have the match part right, but maybe someone can help. I have this url- http://www.foo.com/MountainCommunities/Lifestyles/5/VacationHomeRentals.aspx And I'm trying to turn it into this- http://www.foo.com/mountain-l...

How do I mod rewrite an entire site excluding a couple of subdirectories?

I've got a small problem. I've got a good setup which mod rewrites all requests to the site - the only thing is it also rewrites directories which I don't want to be included. I'm using this code in my .htaccess file: RewriteEngine on RewriteRule ^([^/\.]+)/?$ index.php?section=$1 [L] RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?secti...

Rewrite fails to catch simple errors.

Recently I've added the tail of this file to optimize url's like site/5/john-doe[.php] instead of site/5/john-doe/[index.php], however, I rather like my custom error documents, and these modifications call a black & white "Internal Server Error" and "additional 404" error page. It might be helpful to know that most of the site will rema...

RewriteRule checking file in rewriten file path exists.

How can you use ModRewrite to check if a cache file exists, and if it does, rewrite to the cache file and otherwise rewrite to a dynamic file. For example I have the following folder structure: pages.php cache/ pages/ 1.html 2.html textToo.html etc. How would you setup the RewriteRules for this so request can be send ...

mod_rewrite generating errors in log

On my site I have mod_rewrite rules to make the URLs more search engine friendly, and it all works fine on the frontend, but I'm getting errors in the error log like this [Thu Jan 22 22:51:36 2009] [error] [client {IP ADDRESS HERE}] File does not exist: /{some rewritten directory} The rules I'm using are rather simple, along the lines...

1 A-record for every subdomain (10000+); any potential issues? Any other solution?

Most solutions I've read here for supporting subdomain-per-user at the DNS level are to point everything to one IP using *.domain.com. It is an easy and simple solution, but what if I want to point first 1000 registered users to serverA, and next 1000 registered users to serverB? This is the preferred solution for us to keep our cost d...

Why does RewriteRule ^page/?$ page.php [L] match site.com/page//

RewriteEngine on RewriteRule ^page/?$ page.php [L] This ends up matching the url www.site.com/page// but internally it acts differently than www.site.com/page/ because the stylesheets and images no longer appear properly. Am I doing something wrong or is this just something I need to deal with if I don't want to go through a lot of tro...

mod_rewrite weird problem

I have a strange problem with mod_rewrite, the rules that are relevant here are: RewriteRule ^(.*)\/igre\-(.*)\.php\?Page=([0-9]+)$ game.php?GameUrl=$2&Page=$3 [L] RewriteRule ^(.*)\/igre\-(.*)\.php$ game.php?GameUrl=$2&Page=1 [L] And a corresponding URL might look something like this: example.com/miselne-igre/igre-shirk.php?Page=2 e...

How do you pass in a redirect URL into a mod_rewritten page

I mod_rewrite my pages very similar to how SO does it. I have www.example.com/users/login/ which will internally use users.login.php which acts as a controller. I want to pass in a parameter as a page to redirect to once the login is complete. If you pass in a relative URL you end up with a very peculiar looking URL because you are pass...

Mod_rewrite with godaddy

I'm trying to get mod_rewrite to work on a client's website who insisted that we use Godaddy web hosting. She's got a shared linux hosting account. Will mod_rewrite work (using .htaccess) and if so, how? I'm not sure if Godaddy uses Apache or not. ...

Query Strings & Mod ReWrite

Hey there, I'm not too inexperienced with ReWrite (not a master either, though) so I was hoping somone might be able to help me. RewriteRule ^$ index.php?page=home [NC] RewriteRule ^adm$ index.php?page=adm_home [NC] RewriteRule ^adm/stats index.php?page=adm_stats [NC] Above is a snippet of my .htaccess file. As you can see, when so...

How can I make friendly urls for my site?

So far I include everything in index.php: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?page=$1 [QSA,L] There are also pages where I use $_GET like this: SELECT * FROM news WHERE id = ".intval($_GET['id']) If I want to view a news I type news?id=1 instead of ?p...