mod-rewrite

.htaccess rewrite without www AND redirect to subdirectory

I'd like to redirect www.example.com/* to example.com/* And at the same time redirect example.com/* to example.com/forum/* But I also have /wiki/ and /blog/ and /style/, so I don't want to redirect example.com/style/* to example.com/forum/style/* This is what I have at the moment, which is not working quite correctly: Opti...

Apache rewrite certain urls to separate part of codebase

Hi, Basically I have 2 separate code bases, v1 and v2 for the sake of this example. I want to redirect a certain area of the v1 site to v2 so we can periodically port the old code to new code. Now, I have done this exact sort of code porting before, I just can't remember the exact specifics and whether we did some apache voodoo to get...

Mod Rewrite and PHP

I am trying to redirect pages using mod_rewrite to the pages with some variables (for using them with PHP's $_GET). To give an example with few lines: When the user enters /c/stg it redirects to item_show.php?id=$1&f=1 (where f is page number). When the user enters /c/stg/2 it redirects to the second page with show.php?id=$1&f=$2. I...

How to redirect www.foo.com/bar to www.foo.com:8080 without changing url?

How to redirect www.foo.com/bar to www.foo.com:8080 without "really" changing the url in the url bar? So I want www.foo.com/bar (+ possible GET parameters / subfolders) to be shown always in the url bar. Can this be done with mod_rewrite? ...

Need help on Apache htaccess redirect rule

I need to redirect from path /articles/20090425-swine-flu-kills.html to /2009/04/swine-flu-kills.html In the original path, the digits after articles are the dates in yyyymmdd format. This to convert to "/yyyy/mm/" in the new path. I suppose need some regex but I am not sure how. Would appreciate help. Thanks ...

500 Internal error when using mod_rewrite in .htaccess

I have no idea why, but every time I do something with a complex pattern for a RewriteRule in a .htaccess file, I get a 500 internal error. My current .htaccess file in its entirety is: RewriteEngine on RewriteRule ^ups/sections/([A-Za-z]{3})/([A-Za-z0-9_-+\.]+)/?$ /dl.php?loct=sec&sec=$1&file=$2 [R=302] I've tried with only "RewriteE...

Apache Virtual Hosts and mod_rewrite conflicts

I've been scouring the net and SO and I can't get around or through this problem. We have a bunch of subdomains and a few dedicated servers. One server does double-triple duty as issue tracking and landing page. Problem is the wildcard landing page doesn't take you to the correct virtual host page sometimes. I've been looking at wildcar...

.htaccess redirect after replace a word?

Hello, I need to use .htaccess file to replace a world in URL something like this: example URL: http://example.com/oldword/test-page.html redirect to: http://example.com/newword/test-page.html how can I use mod_rewrite to redirect every URL containt "/oldword/" to the same URL after replacing that word? ...

Cannot get started with mod_rewrite

I have in the past successfully managed to copy/edit/paste rewrite rules on an apache server over which I had limited control. Now however I am experimenting with an Apache server which I can restart and configure to my heart's content but I cannot get even a basic rewrite example to work and that is after I have read at least two tutor...

How to correctly rewrite url?

While rewriting url in php from dynamic to static... suppose url story.php?id=12 is rewritten now when in story page i will read $_GET['id'] it will return null.... How to do this correctly? ...

Point an <img> tag to a image dynamically generated by PHP?

Is it possible to redirect an image to a dynamically generated image(using PHP)? I have a dynamically created image and it has an extension ".PHP" (obviously) and that server is not under my control. So I want to redirect "somename.jpg" (on my server) to "remoteserver/dynamicimage.php" (on some remote server not under my control) so th...

URL rewriting-page not found error

In order to convert my dynamic URL i.e www.3idiots.co.in/index.php to static url i.e www.3idiots.co.in/index.html, I edited my .htccess file and put the following code in it: RewriteEngine On RewriteRule ^index.php$ /index.html [R] when i uploaded this file in the root directory,and try to open the page, I got the error 404 page n...

mod_rewrite or mod_alias ?

I have a server, it's httpd.conf already has some "RedirectMatch permanent" directives in it. I'm not that familiar with mod_alias, I've only ever used mod_rewrite. What's the basic difference? I don't see a "L" flag in mod_alias to stop processing rules. Which one should I use for best practices of redirecting from one subdomain to ...

mod_rewrite : why does it work locally and not online ?

I'm developing an app locally (under Domain name <mydomain>.dev). In order to work with friendly urls, i've set up my .htaccess like this: RewriteEngine on # Externally redirect to add missing trailing slash RewriteRule ^(([a-z0-9._\-]+/)*[a-z0-9_\-]+)$ http://example.com/$1/?%{QUERY_STRING}[NC,R,L] RewriteRule ^about/$ about.php [NC,L...

mod_rewrite help to pass full path with query string

I'm doing some caching based on the whole url, including query string, and need Apache to recognize the file and use it. It seems to find a match but then strips the query string off before rendering the file. url: www.somesite.com/default.asp?foo=bar Cached page filename on the filesystem in the cache folder: default.asp?foo=bar My c...

re-direct / re-write my domain

firstly, i have already spents the past few hours trying to find a solution for this, but have had nothing but non-working solutions :( it's pretty simple - i'm pointing the DNS of a new domain to my current hosting. but when i visit the new domain, i'm just viewing my original site (the one i got with my hosting). let's say my origina...

mod_rewrite if you use an expression all over the place, can you put it in a "variable"?

If I use the following like 50 times in my htaccess file: RewriteRule ^(bla|blo|bli|blu|bloi|bkdo|doid|boidi|woekj|dfpo8ds)/?$ /section_index.php?sectionurl=$1 [L] is it then possible to just put bla|blo|bli|blu|bloi|bkdo|doid|boidi|woekj|dfpo8ds in a variable instead of using it again in every line? If so, how do I do that? ...

Match Question Mark in mod_rewrite rule regex

I am looking to rewrite urls with multiple substrings. One substring is being requested as a subdirectory, while any others are requested as normal query string parameters. For example, I would like to rewrite urls from http://www.mysite.com/mark/friends?page=2 to http://www.mysite.com/friends.php?user=mark&amp;page=2 I am able t...

Diggbar modrewrite- How do they pass URLs through modrewrite?

With the new Diggbar, you can put http://digg.com in front of any URL that you are currently at and it will create a Digg short URL. I am only assuming they do this by modrewrite (though I am not sure since I am new at this all). How is this done? It seems to me when I try this with a website I am working on, it bombs out. I want to ...

[mod-rewrite] foo.com/city/staticpage-cityname.html --> foo.com/staticpage-cityname.html

My current solution is to put everything in the site root although it gives the desired result it has crowded my root folder (more than 200 cities). I would like to put all the cities in /root/cities/ folder and rewrite so that it looks like they are in the root folder. www.foo.com/cities/citypage(.html) to www.foo.com/citypage(.html) ...