mod-rewrite

Problem with RewriteCond %{QUERY_STRING}, backreference not dispaying in final URL

Hi, I have the following in my .htaccess file: RewriteCond %{QUERY_STRING} ^route\=product\/category\&path\=35\&page\=([0-9]+)$ RewriteRule ^index\.php$ http://%{HTTP_HOST}/product/category/35/page_$1? [R=301,L] It's not behaving as expected though, when I enter the URL: http://example.com/index.php?route=product/category&path=3...

.htaccess: Rewrite Problem.

Hi, I'm creating a website. I have this code in the .htaccess file: RewriteEngine On RewriteRule ^/([-a-zA-Z0-9_]+)/$ /redirect.php?id=$1 But when I go to, for example /ASEi it says 404 Not Found. What's the problem? ...

Apache Rewrite problems with my blog

Hey Guys, I am having a hard time getting the rewrite rule setup correctly for my website&blog. Here is the current line in Apache's virtual host: RewriteRule ^/(?:blog|apc|_em|phpsecinfo|blog/)/ - [L] I am able to access my URL at www.domainname.com/blog/ But I am unable to access it at www.domainname.com/blog (without the ending ...

Apache mod_rewrite replace characters in REQUEST_URI

I'm trying to write some .htaccess rules that replace certain characters in the REQUEST_URI parameter. Specifically, I want to replace the following: "<" = &lt; ">" = &gt; "'" = &apos; '"' = &#x22; ")" = &#x29; "(" = &#x28; Example URL could be http://www.example.com/?&lt;script&gt;alert(1)&lt;/script&gt;&amp;q=")("&lt;script') I'v...

how to convert Apache mod_rewrite rules to Microsoft URL Rewriter IIS7?

can someone tell me how to convert apache iis7 mod_rewrite .htaccess file to the equivalent web.config in MS Url Rewriter? Here is the .htaccess file I have: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L] </If...

Lighttpd rewriting files and directories

I'm trying to do url rewriting with Lighttpd. I have what I need partially working. Right now I have this: http://domain.com/name/a/123 which rewrites to http://domain.com/name/a.php?pid=123 I do this with this rewrite-once rule: "^/name/a/([^/]+)"=> "/name/a.php?pid=$1" That php page has external resources that are not getting rewritt...

.htaccess redirect domain alias / parked domain

Hi... I have a .htaccess related question. For example, if I have two domain, a.com and b.com. All referring to one host (b.com is domain alias of a.com). I want visitor that visit a.com will be referred to url with www (http://www.a.com). As for the visitor of http://b.com will be referred to the www url (http://www.b.com). How can I...

How do I set up mod rewrite to do this?

Hi guys heres the scene - I'm building a web application which basically creates accounts for all users. Currently its setup like this the file structure: root/index.php root/someotherfile.php root/images/image-sub-folder/image.jpg root/js/somejs.js When users create an account they choose a fixed group name and then users can join th...

Should I use java-based rewrites instead of mod_rewrite?

I want to implement some attractive /path/to/my/app URLs for a java application. There is already an apache instance in front of the app server, with mod_rewrite installed. Do I win anything by using a java-based rewriter like UrlRewriteFilter instead? ...

Rewriting a Subdomain with mod-rewrite

I have a project that uses the moodle library. I had to change the URL from moodle.example.com to learn.example.com, due to a client request. I thought this would be an easy change, but alas moodle inserts all links and images in with the complete url instead of the relative url. Is it possible using mod-rewrite to point all requests t...

php website url matching question

hi, i am new to a php site, only familiar with .net web forms sites. i can't figure out how routing is working on this php site. www.oursite.com/suggestions.php is to suggestions.php www.oursite.com/suggestions also loads the php fine www.oursite.com/suggestions/ loads the php, but no css is applied www.oursite.com/suggestions/anythin...

HTACCESS Rewrite on directories

I have the following code in my Root htaccess file RewriteCond %{HTTP_HOST} ^paperviewmagazine.com RewriteRule (.*) http://www.paperviewmagazine.com/$1 [R=301,L] It works fine for the main site, but for my forums at /forums/ if someone misses off the www it will show the page and not redirect to the www.paperviewmagazine.com/forums/ i...

How Can I ReWrite flat link to a dynamic link and preserve the Query string?

Hello All, I am wanting to rewrite a url like: http://my.project/mydomain.com/ANY_NUMBER_OF_CATEGORIES/designer/4/designer-name/page.html to this: http://my.projects/mydomain.com/ANY_NUMBER_OF_CATEGORIES/page.html?designer=4 I would like to use mod-rewrite to accomplish this. Things to note: Any number of categories can be between ...

Mod Rewriting Image Location Not Working Very Well

Hey, I'm trying to mod rewrite the image locations on my site, I'm just using this : rewriteRule ^thumbs/(.*)$ http://site2.com/thumbs/$1 [L] so that I can redirect all image requests going from http://site1.com/thumbs/something to http://site2.com/thumbs/something But only some of the images are loading, and not all of them. The ...

Rewrite only URLs that don't exist

I'm looking for a way to rewrite URLs only if the path doesn't exist. This isn't to handle 404s, but to redirect page URLs to a shared PHP file (ie: '/contact-us/' -> '/show_page.php?page=contact-us'). The basic redirect is easy enough to achieve, however I want to be able to override the default page by adding '/contact-us/index.php' i...

How do I prevent access to domain subfolders when hosting two domains using the same webspace?

I have two domains that point to the same root folder of my webspace. My root directory is setup like so: /domain1 /domain2 /shared Where requests to... http://www.domain1.com/* should do an internal redirect to http://www.domain1.com/domain1/* http://www.domain2.com/* should do an internal redirect to http://www.domain2.com/domain...

Disabling compression for IE pre SP2 with Apache mod_rewrite

I am trying to replicate this fix ( http://sebduggan.com/posts/ie6-gzip-bug-solved-using-isapi-rewrite ) with Apache mod_rewrite, but with no success... Can somebody help me translate those ISAPI rules to APACHE mod_rewrite? I don't know how to 'translate' those rules... My objective is to avoid sending compressed css and js when the us...

Problems with mod_rewrite, help!

I have the php mail function on a page but every time I load that page, I wil get 8-12 mails instead of 1 mail. The problem is the htaccess I suppose. My .htaccess: Options +FollowSymLinks Options -MultiViews RewriteEngine On RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d...

Properly 301 redirect an URL with parameters to a different site

Right now I have an outdated URL that is getting 404'd: http://mysite.com/category/?tag=blue-example It needs to be redirected to: http://subdomain.mysite.com/blue/ This doesn't work: Redirect 301 /category/?tag=blue-example http://subdomain.mysite.com/blue/ How do I properly rewrite this URL? ...

Mod Rewrite: I want to redirect all requests to index page unless the file exists (but not if the file is a php file)

I have a .htaccess file like this right now. It sends everyone to the index page unless you wanted a real file. This is sort of what I want, but I dont want anyone to be able to access a .php file. So this is what I have: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f [NC] RewriteRule ^(.*) /index.php [NC] But this is what I wan...