mod-rewrite

PHP: Parse different styles of friendly urls

Hello. I am writting my own small framework and I am going to implement friendly URLs there. mod_rewrite is great. But I want to be able to handle several types of friendly URLS at once: /index.php?ac=user&an=showprofile (fallback variant, the worst) /index.php/user/showprofile (supposedly, can be disabled by security settings) index.p...

Disable QSA in IIS Mod-Rewrite

So I've got http: //www .domain.com/page.cfm?var=test redirecting to http: //www .domain.com/404.cfm?var=test I don't want the variable string included in the url at redirect. Kicker is I don't have QSA in the condition. So is QSA on by default for IIS Mod-Rewrite? If so how can I turn it off? RewriteRule ^(?:factory_outlets|public_st...

Apache mod_rewrite, redirect to an URL when a file with a particular extension is requested

Hi! I would like to use mod_rewrite to transform a URL like this one: http://example.com/qxs/app/myapp.qxs into http://example.com/qxs/index.php?page=myapp Currently I have this: Options +FollowSymlinks RewriteEngine on RewriteRule ^app/([^/\.]+).qxs /qxs/index.php?page=$1 [L] But this ends up in an endless loop or something ca...

Browser language based 404 pages with mod_rewrite how to

I am trying to generate language dependant 404 (also other errors) pages purely based on Apache mod_rewrite rules by evaluating the clients HTTP Accept-Language header. I've managed to show the correct pages (english default) with this rules: RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{SCRIPT_FILENA...

Apache mod_rewrite rules problems

domain.com/index/ to domain.com/index.php domain.com/index/hello to domain.com/index.php/hello The site is use path_info,and the default rule not works: RewriteRule ^([^/]+)/(.*)$ $1.php/$2 [L] I change to: RewriteRule ^([^/.]+)((/[^/]+)*)/?$ $1.php$2 [L] That was strange domain.com/index/ to domain.com/index.php works fin...

Removing Tomcat context from URLs for a virtual host (mod_jk, mod_rewrite)

Hi All, I have a single Tomcat instance containing a number of webapps, each accessible via it's /Context. Tomcat is behind httpd (actually Debian Apache2), configured with virtual hosts to serve each app/Context. Tomcat connectivity is with mod_jk. This works fine when I don't care about removing the context from urls: when the root ...

Apache Rewrite Rule Regex Problem

So I have an Apache .htaccess file that contains this: RewriteEngine On RewriteRule ^/(javascript/.*)$ /$1 [L] RewriteRule ^/(styles/.*)$ /$1 [L] RewriteRule ^.*$ /index.php Unfortunately, the last line's coughing up a 500 error on the server that we've moved the code to. It works fine on my machine, Ubuntu 9.10 running Apache 2.2.12,...

Using RewriteRule in .htaccess for POST request

I am attempting to lock down a page to only accept POST requests. as part of an RESTful API. I have the following, but it doesn't seem to work. Any help would be appreciated. RewriteCond %{REQUEST_METHOD} POST RewriteRule ^api/(call1|call2|call3)/?/ http://www.example.com/api/rest_services.php?_call=$1 [L] ...

mod_rewrite convert certain folders to parameters

Hi I have a site where I'd like to convert the first subfolder into a parameter (from a set list of subfolders), so http://localhost/mysite/folder1/dosomething.php is displayed as shown above, but to PHP it looks like: ... localhost/mysite/dosomething.php?organisation=folder1 I only need to do this on certain folders (i.e. not ... l...

Adding .html onto the end of a URL

I'm currently using Wordpress as a blogging platform but I want to change to use Jekyll to generate the static pages. On Wordpress my URLs use the following format: /year/month/day/title but I want to redirect that to /year/month/day/title.html and I can't figure out how to do that using mod_rewrite. Anyone got any ideas? ...

Speed of RewriteRule?

I have a site that is roughly one half "my" site, and one half a SAS site from a third party. We've been trying to tackle a single sign on method for many moons. It dawned on me recently that if I did some URL rewriting to display the third party site, but appear on our domain, the third party cookies would be written as coming from my...

Need help with Apache's mod_rewrite to fetch file based on url

So say I have a url being requested: sub.domain/file.bin and I wanted this file to be fetched: domain/hosted/sub/file.bin How would I structure the rewrite directives? I've been working on this for days, and it just gives me a headache... The subdomains are numerous and are added and removed often, so I'm trying to find a solution ...

Apache / mod_rewrite / Periods messing with pattern

First question, here goes nothing... I'm trying to add a new entry to my .htaccess file (Apache server) with the hopes of translating this URL: http://platform.localhost/category.all into this URL: http://platform.localhost/index.php?page=category.all The RewriteRule that I'm currently using is this: RewriteRule ^([^/\.]+)\/?$ in...

mod rewrite problem

Hi, I am trying to redirect my pages using URL: RewriteRule ^(.*)/content/(.*)/?(.*)\.html$ browse.php?s=$1&c=$2&l=$3 [NC,L] For 2 parameters it works fine but when I passes 3 parameters it merges the 2 and third. Correct output is as follow (2) parameters: Array ( [s] => wallpapers [c] => Global_Celebrities [l] => Nicole1); ...

Strip part of URL or with mod_rewrite

I'm helping someone with a Wordpress blog which at one time was at http://example.com/example/ Now they've move the blog to the root of the site and want to redirect any of the old links to the correct site. Wordpress has it's own re-write rules in .htaccess already: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCon...

mod_rewrite to a directory

Hi everyone, Im trying to create a rewrite rule to a different directory, but unfortunatly its not working. My current rewrite sends everything back to the index.php file unless the first word in the query string is admin. The rewrite rule for 'admin' is to admin.php, but i actually want it to go to /var/www/html/website.com/admin/admi...

How to keep URL display unchanged after redirecting root folder to sub folder

I want to redirect all queries to mydomain.com to mydomain.com/live/. I'm already able to do that, however I have trouble with the URL displayed in the browser. I have two goals, (1) that the URL always renders with "www" in front and (2) that the sub folder "live" is not displayed in the url. EDIT: Based on edited code by Cryo the fo...

mod-rewrite index.php

I have these urls: index.php?area=guilds index.php?area=guilds&page=create index.php?area=guilds&page=view&name=The+Unit Could I have only 1 rewrite rule for this somehow? /guilds /guilds/create /guilds/view/The+Unit ...

.htaccess rewrite with REST style URL 500 error

Hi All, I'm trying to implement a REST-style URL with a mod-rewrite turned on in .htaccess. There's a bit of a kicker which is that I'm developing in a test environment (new cpanel account). Here's the .htaccess: RewriteEngine on #REMOVE THIS LINE ON SITE LAUNCH! RewriteBase /~myNewAccount/ #Hide .php extensions for cleaner URLS Rew...

mod_rewrite Probs

Hi Guys, I am quite new to PHP and just getting started with mod_rewrite. I know the basic lingo but come stuck when I want to simply refer to the route directory i.e. this is not probs RewriteRule ^settings/$ settings.php [QSA,L] But how to for example make: RewriteRule ^page/(.*)$ index.php?Page=$1 [QSA,L] which gener...