views:

494

answers:

2

I'm running Apache on my local computer (mac) with Mod_Rewite enabled and Allowoveride All set in XAMPP's httpd.conf file.

These are my rules, snippet of httpd.conf file -

RewriteEngine On
RewriteRule ^/setup/css/userlayout.css /setup/css/userlayout.php

Alias /ms "/Users/web/wwwroot/ms"

<Directory "/Users/web/wwwroot/ms">
    Options Indexes MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

In my index.php file I have -

<link rel="stylesheet" type="text/css" href="setup/css/userlayout.css?u=1" />

And in my userlayout.php file is -

<?php
    header('Content-type: text/css');
    echo "#test{background-color:#000;}";
?>

Thats everything but the rules don't do anything. I'm not sure if I'm putting the rules in the right place and I understand that you can do this in a httpd.conf file and not the .htaccess file.

+1  A: 

Hello. Try using this:

RewriteRule ^/setup/css/userlayout\.css$ /setup/css/userlayout.php

You can see more about RewriteRule here.

Nathan
Nope nothing. I suspect there is nothing wrong with the rule. Infact I can't prove if mod-rewrite is working at all except if put in RewriteBase / I get a big error message which I shouldn't be getting at all. hmmm....
EddyR
If you are using the latest version of XAMPP (for windows) I'm quite sure it is installed and active by default.
Nathan
must be something else then. anybody got any ideas?
EddyR
A: 

I figured out what the problem was. XAMPP setup requires the line "Options +FollowSymLinks" for mod_rewrite to work. Also this has to be placed within the directory tag not outside of it as rewrite rules work per directory which is why i was receiving the error on "RewriteBase /" directive.

Thus the full code is:

<IfModule mod_rewrite.c>
    Options +FollowSymLinks 
    RewriteEngine on
    RewriteBase /root
    RewriteRule ^setup/css/userlayout\.css$ setup/css/userlayout\.php
</IfModule>
EddyR