mod-rewrite

Rewrite rule index.php?/controller/method/param to /controller/method/param

I need a rewrite rule for this url http://localhost/~user/frame/lib/index.php?/controller/method/12/22/ How can i rewrite it that i can call it like this http://localhost/~user/frame/lib/controller/method/12/22/ What is the rewrite rule for the above problem? I hope i could explain my question clear. ...

Help with redirect and query strings

I'm a total novice at mod rewrite so I'll try and present my question as clearly as possible: I'm trying to create a url redirect of the following (static) affiliate url that can append it self to any product links after using a query string: affiliate url: hxxp://clk.affilite.com/fs-bin/click?id=aFb*BBBBBpQ&subid=&offerid=9999.2&type=...

How to capture a 'sub-section' of a URL in a rewrite rule?

I know the title is a little bit strange, but here is what the URLs look like: /user/xxx/page /user/xxx/page?error=yyy The rule for the first URL looks something like this: RewriteRule ^user/(\d+)/page$ something.pl?id=$1 [L] And to make it work with the second URL, it becomes: RewriteRule ^user/(\d+)/page(error=\d+)?$ somet...

How come the [L] flag isn't working in my .htaccess file?

Here are the rules: <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^$ index.php?action=home [L] RewriteRule ^[\w\W]*$ error.php [L] When a page matches the first one, it is supposed to ignore any other further rules. Yet accessing / results in error.php being invoked. Commenting out the second rule works as intended - the page...

How to make a catch-all handler in an .htaccess file?

I want to create a rule at the end of an .htaccess file that catches everything that failed to match up until then. How can I do that? P.S. I've already tried everything :) Actually, I haven't, but it sure seems like it! Update: Some people are replying with RewriteRule ^.*$ or an equivalent. This does not work! It will match everythi...

Symfony on virtual host (document root problem)

Hello, I'm developing an application in Symfony and on localhost (XAMPP) I want to simulate the same conditions as on the webserver. The web server is configured as follows: /www => mydomain.com /foo => foo.mydomain.com /bar => bar.mydomain.com ... I'm going to put my Symfony application into /www direcotry so there'll be: /ww...

mod_rewrite help can't get it to work

This is the first time I use mod_rewrite and I can't get it to work. I have a website with bands and their IDs. What I want: a URL /bands/My_Band_id13/ should redirect to /bands/index.php?bandname=My_Band&bandID=13 What I have: RewriteRule ^/bands/(.*)_id(.*)/$ /bands/index.php?bandname=$1&bandID=$2 What am I doing wrong? ...

change cat-art.php into cat/art.php

Hi i got a problem with changing urls. I have files: cat-art.php (cat- category, art- title of an article) and i would like to have nicer access to them: cat/art.php so i wrote some code in .htaccess but it doesnt work. RewriteCond %{REQUEST_URI} ^/([^-]+)/([^-]+).html$ RewriteRule ^([^-]+)/([^-]+).html$ $1-$2.html [L] Can sb help me...

Making dynamic images have static filenames

My website currently has various links to a php script that generates the images dynamically. For example, the link may say "img source="/dynamic_images.php?type=pie-chart&color=red" Obviously, this is not great for SEO. I'd like to somehow make the filenames of these links appear to be static, and use a solution (like Mod-Rewrite) t...

mod_rewrite - Don't get a second rule work

I want to have a url like this: domain.com/css/site.css?test=234 Rule: RewriteEngine On RewriteRule ^([a-z]+)/$ $1.php RewriteRule ^css/([a-zA-Z0-9]+).css?count=(.*)$ css.php?f=$1&test=$2 But I get every time a 404: Not found (site.css) If I have a rule like that it works, just without getting the $_GET-Variable: RewriteEngine On R...

RewriteRule - how to redirect from a folder within a folder to a new domain?

Hi, I've been struggling with the following rule: RewriteRule ^subdomains/example.com/(.*)$ http://www.example.com/$1 [R=301,L] I'm trying to redirect anything that occurs after the folder /subdomains/example.com/ to http://www.example.com/ whilst including any filename or extra folder path information. E.g: www.olddomain.com/subdoma...

DirectoryIndex not working because of mod_rewrite?

Requests to www.domainname.com and domainname.com should display index.html, not index.php as it does now. This is the .htaccess file: # -FrontPage- IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On # RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond ...

RewriteCond simply doesn't work, doesn't check properly if file exists

Hey everybody. I've been trying to solve this for hours now but came up with nothing. Inside .htaccess, whenever somebody requests an image from a folder of my website, I'm trying to check if a file with the same name exists in another folder; if it does, return that file; if it doesn't, return the file originally requested. It seems ...

Apache Rewrite & Alias combined

Hello, We have run into an issue where we have an existing Alias, and we would like to add a rewrite rule to catch all variations of case-insensitive spellings, ie: URL: http://www.example.com/example Alias /example "/var/www/html/web/example" We need a rewrite rule to catch: /ExamPle /exampLE /eXAmple etc ... If anyone could...

Writing .htaccess mod rewrite for hierarchical categories

i need to rewrite urls for my classified ads directory i have 4 types of links /City ==> display all ads in city /City/Cat1 ==> display all ads in city + category /City/Cat1/Cat2 ==> display add ads in city + category 1 + category 2 /City/Cat1/Cat2/Ad-id ==> display the ad itself and pass cat1 cat2 and city variables original hidd...

RewriteRule and php download counter

(1) I have a site that serves up MP3 files: http://domain/files/1234567890.mp3 (2) I have a php script that tracks file download counts: http://domain/modules/download_counter.php?file=/files/1234567890.mp3 After download_counter.php records the download, it redirects to the original file: Header("Location: $FQDN_url"); (3) I'd li...

Jetty RewriteHandler and RewriteRegexRule

I'm trying to rewrite a URL for a servlet. The URL gets rewritten correctly, but the context doesn't match after that. Any idea how to get this to work? RewriteHandler rewriteHandler = new RewriteHandler(); rewriteHandler.setRewriteRequestURI(true); rewriteHandler.setRewritePathInfo(true); rewriteHandler.setOriginalPathAttribute("reques...

RewriteRule - Doesn't work on live site - subfolder to new domain

I have the following rule on my local dev site and it works fine: RewriteCond %{HTTP_HOST} ^localhost$ RewriteRule ^subdomains/example\.com(.*) http://www.example.com$1 [R=301,L] However when I change it to: RewriteCond %{HTTP_HOST} ^www.some-domain.example$ RewriteRule ^subdomains/example\.com(.*) http://www.example.com$1 [R=301,L] ...

How to write rewrite rule in htaccess file.

I have a problem with rewrite rule my link is www.something/group/group_id/place/groupName for this rewriteBase / RewriteRule ^group/(.*)/(.*)/(.*)$ /group.php?gid=$1 [QSA,NC,L] somet times my url may come www.something/group/group_id/groupName. In Both cases I have to rewrite to group.php and I need only groupid. How to write rewr...

Simulating a 2-level If-Else using RewriteCond

Hi! I'm trying to get my head around RewriteCond, and want to rewrite any requests either to a static html page (if it exists), or to a specific index.php (so long as the requested file doesn't exist). To illustrate the logic: if HTTP_HOST is '(www\.)?mydomain.com' if file exists: "/default/static/{REQUEST_URI}.html", then ...