mod-rewrite

mod_rewrite taking over all the links on the page

...

How do I make Apache know which app directory to use for different domains?

I'm trying to create a site with CodeIgniter. I will have multiple domains served from this server, and what I am trying to do is to separate the HTTP requests for www.example1.com from the ones for www.example2.com and then redirect them to the their correct application folders. Say this is my directory structure: system application...

500 Server Error: Infinite rewrite loop in Apache 2.2.x with mod_vhost_alias, VirtualDocumentRoot, and mod_rewrite for routing / "pretty" URLs

I'm running into a problem using Apache's mod_vhost_alias directives and mod_rewrite for routing "pretty URLs" with a local development machine. I know that it's possible to do so, because my hosting provider uses a similar configuration and has no problems. However, whenever I try on my local machine, Apache returns a 500 Internal Serve...

Can I do a 301 on a mod rewrited url with no extension?

I am running a site that has mod rewrites running on it I am running into a issue when I delete or archive a product. All my rewrites, rewrite to file names without extensions I want to re-driect that old page to a new page or the archived product page. Now since there is no .html or .php extention on the link when I do a mod rewrite ...

How can I make my .htaccess skip rules conditionally?

I want to redirect all URLs that do not contain "_js","_css", "_img", etc., to my dispatch script. Somehow it doesn't work. For instance, all files inside my /_js/ folder are unaccessible (meaning: they are sent to index.php instead of getting to the physical files residing in that folder). Here is my htaccess: IndexIgnore * Options +...

How to: URL re-writing in PHP ?

I am trying to implement URL rewriting in my PHP application. Can someone share a step by step procedure of implementing URL rewriting in PHP - MYSQL. In my application I want to implement following URL rewriting, I want to redirect 1. http://example.com/videos/play/google-io-2009-wave-intro 2. http://example.com/videos/play/203/googl...

Redirect domain.com/folder to folder.domain.com permanently

Possible Duplicates how can I use mod rewrite to redirect a folder to a subdomain ... Apache rewrite based on subdomain (backwards) I have catch all rules set up and a subdomain working fine. However it's still possible to get to a part of my site from http://example.com/subdomain rather than http://subdomain.example.com/ Ho...

Apache RewriteRule not working without Page # specified.

Hello All, I have a rewrite rule set up in my .htaccess file: RewriteRule ^Crocodile-Style/([0-9]+)/?$ products/display.php?folder=crocodile-style&page=$1 [L,NC] http://test.bradp.com/drupal/Crocodile-Style/1 works OK. http://test.bradp.com/drupal/Crocodile-Style/ DOES NOT WORK. Apache throws a 404. The PHP logic defaults to page 1...

How do I make my urls work with mod_rewite?

Hey everyone, I'm having rewite issues. http://test.bradp.com/drupal/Crocodile-Style/1 works OK. http://test.bradp.com/drupal/Crocodile-Style/ DOES NOT WORK. Apache throws a 404. The PHP logic defaults to page 1 without a page specified, so I know the script is fine. Here's the code: RewriteRule ^Crocodile-Style/([0-9]+)/?$ products/...

Simple mod_rewrite problem

I am new to using mod_rewrite and am trying to rewrite pages at the base level of my site: www.site.com I want to rewrite any of the following URLs www.site.com/main www.site.com/settings www.site.com/username To: www.site.com/index.php?v=main www.site.com/index.php?v=settings www.site.com/index.php?v=username I had this working when...

htaccess: Why doesn't this work?

I get a 404 error page when I try the following rule in htaccess: RewriteRule ^Test\?service=(.*) test.php?foo=$1 [NC,L] How come? I know it's preferable to use something like ^Test/(.*) test.php?foo=$1 [NC,L] instead, but in this case I'd rather like it the way I stated. Thank you in advance. ...

Force a prettified URL with mod_rewrite

So have rewritten my ugly php URL to something prettier: RewriteEngine On RewriteRule ^main/photo([^/\.]+)/?.html$ main/details.php?gid=$2pid=$1 However, now I want to force anyone who goes to http://www.example.com/main/details.php?gid=20&pid=5 to redirect to htto://www.example.com/main/photo5.html I have tried the follow...

conditional rules htaccess

hi, Currently, my .htaccess file looks like htis: IndexIgnore */* RewriteEngine on RewriteRule ^add /add.php RewriteRule ^add/$ add.php RewriteRule ^sitemap.xml /xmlsitemap.php RewriteRule ^([^/\.]+)$ /index.php?slug=$1 RewriteRule ^([^/\.]+)/$ /index.php?slug=$1 It works fine for links as: site.com/category/ However, i would like t...

Help with regular expression with mod_rewrite

Hi, I have links like these that I want to change: mypage.com?page=missions&id=5 mypage.com?page=hello I tried to change them into easier links with this: Options +FollowSymLinks RewriteEngine On RewriteRule ^([^/]*)/([^/]*)$ /index.php?page=$1&id=$2 [L] It works but if I want to access pages like (mypage.com?page=hello) I have to ...

mod_rewrite error 404 if .php

I rewrite my urls to be user friendly. For example I have a page called user.php that I rewrite to /user. But a user can still use user.php. Can I redirect to a 404 if they request a page with a .php extension? Options -MultiViews +FollowSymlinks -Indexes RewriteEngine on RewriteRule ^user/([0-9]+)$ user.php?id=$1 [L,QSA] Thanks. ...

HOWTO: rewrite requests for images, css and js to different folders for each application?

I am trying to build a multi-app CodeIgniter site, where the assets for all apps will be stored in a single folder called “assets.” Inside this single folder, each app would have its own asset folder. So, if this is my root directory… user_guide apps_folder (this is where all my application folders live) system assets ...the ass...

htaccess mod_rewrite with dynamic parameters

Hello! I am new to mod_rewrite. I am trying to forward a URL to another one, but I cannot get it to work. Say I want to forward this URL: /cansas.php?m=2&id=2-0-0-0&sid=cansas to /cansas-is-good-for-you and let the header respond with a 301, or just update the URL through [R]. I have this in my .htaccess: Options +FollowSymlinks ...

htaccess redirect append query string?

I have an htaccess redirect that needs to forward the query string to the new URL, but it's getting dropped after the redirect. Can someone tell me what's wrong? RewriteRule ^services/agents.*$ https://services.example.com/agents/ [R=301,L,QSA] ...

Mod_Rewrite - Skip rule if .php extenstion exists

I cannot figure out a way to skip the next rule if a .php extension exists in the url Here is what I'm currently using RewriteCond %{REQUEST_URI} !\.php RewriteCond %{REQUEST_URI} \/([0-9a-z]*)$ [NC] RewriteRule ^(.*) index.php?un=$1 [L] ...

Remove trailing slashes

Hello, I'd like to work with pages without trailing slashes. So now I want my URL's with an trailing slash to redirect (using .htaccess) to the same URL without the trailing slash. I got two .htaccess files: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule (.*) public/$1 </IfModule> And one in my public folder: Directory...