.htaccess RewriteRule Problem

Problems with the Mac OS X version of XAMPP, questions, comments, and anything related.

.htaccess RewriteRule Problem

Postby redlettuce » 06. August 2012 19:23

I'm using XAMMP on my Mac with virtual hosts set up and working fine. Currently developing a site for a friend and trying to use mod rewrites via .htaccess. This seems to be working fine while I'm navigating to main pages from the menu, e.g. domain.loc/ or domain.loc/films but once I try to dig further, I'm getting issues, so domain.loc/films/london will throw an error because PHP is then looking for an include called "london" rather than "films".

Here is my .htaccess file (it's very basic):

Code: Select all
#AddType text/x-component .htc

RewriteBase /

RewriteEngine on

RewriteRule ^new/$      /new.php
RewriteRule ^new$      /new/ [R]

RewriteRule ^films/$      /films.php
RewriteRule ^films$         /films/ [R]

RewriteRule   ^offline/$      /offline.php
RewriteRule ^offline$      /offline/ [R]

RewriteRule ^contact/$      /contact.php
RewriteRule ^contact$      /contact/ [R]

RewriteRule ^films/([a-zA-Z0-9-]+)/$   /films.php?mov=$1
RewriteRule ^films/([a-zA-Z0-9-]+)$      /films/$1/ [R]

PHPinfo() is showing that mod_rewrite is working, but .htaccess appears to be ignored completely! The rewrites work if I remove it from the root directory and making changes to it makes no difference.

I have bashed the .htaccess file and it's giving me "command not found" errors on every line, including "RewriteEngine on" and "RewriteBase /", It's also throwing me an "error near unexpected token" message on line 19.

I'm not expert in this but this has got be baffled - I've Googled but have not found anything like what I'm experiencing. It's really confusing me that the rewrites from domain.loc/films/ to /films.php are still working even when I completely remove the .htaccess fils from the folder.

Oh - when I upload to a web server I use for my actual hosting, it works fine, even with query strings, so it's presumably something to do with my setup rather than my .htaccess...

Any help you be appreciated!



Mac OS X Lion 10.7.4
XAMPP 1.7.3
PHP 5.3.1
Posts: 1
Joined: 06. August 2012 19:02
Operating System: Mac OS X Lion

Return to XAMPP for Mac OS X

Who is online

Users browsing this forum: No registered users and 2 guests