Page 1 of 1

rewriting with htaccess

Posted: Fri Jan 27, 2006 2:13 am
by tauqeer
hi, i am new to php and trying to rewriting with htaccess this is what i am doing

RewriteEngine on
RewriteRule ^index\.php$ index

just trying to show "index" when "index.php" is written in url and i am getting the error 500
i dont know it is a configuration problem or i am not writing incorrectly please help me in this

[edit] this error is coming if i just try to redirects a page, this is what i am doing
Redirect index.php http://localhost/shopping/cart.php

and apachi log file is createing the following error

[Fri Jan 27 15:24:21 2006] [alert] [client 127.0.0.1] c:/program files/easyphp1-8/www/shopping/.htaccess: Invalid command '\xff\xfeR', perhaps mis-spelled or defined by a module not included in the server configuration

i have already uncomment following lines in config files

LoadModule rewrite_module modules/mod_rewrite.so
AddModule mod_rewrite.c

Posted: Fri Jan 27, 2006 9:58 am
by shiflett
You could just name the file index instead of index.php and use ForceType to force it to be interpreted as PHP. It seems more straightforward than using mod_rewrite in this particular case.

Posted: Sun Jan 29, 2006 4:05 am
by tauqeer
thanks for the post shiflett. that problem is solved i was not saving file as asci but as unicode but now i am facing a new one i am writing the same code for rewriting the url and when i open the page on localhost it redirects me insted of rewtiting and if i am not giving the name of page it assums it a directory as in the following case. could someone please tell me that i am doing wrong i just want to display "index" whenever index.php is called.. here is the code again

RewriteEngine on
RewriteRule ^index\.php$ index

i am using apache 2 and php 5

Posted: Sun Jan 29, 2006 8:36 am
by John Cartwright
remove the slash

Posted: Sun Jan 29, 2006 6:26 pm
by josh
If you want the url in the go bar to change like a header redirect you need a R flag

Code: Select all

RewriteRule original rewritten.php [R]