rewriting with htaccess

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
tauqeer
Forum Newbie
Posts: 2
Joined: Fri Jan 27, 2006 2:06 am

rewriting with htaccess

Post 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
User avatar
shiflett
Forum Contributor
Posts: 124
Joined: Sun Feb 06, 2005 11:22 am

Post 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.
tauqeer
Forum Newbie
Posts: 2
Joined: Fri Jan 27, 2006 2:06 am

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

remove the slash
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post 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]
Post Reply