Web Hosting Talk







View Full Version : htaccess and php


kneuf
12-17-2003, 08:34 AM
I've been searching the 'net for a little while now, but can't seem to find any good examples/tutorials for this. I would like to make it so that, for example, a person types in: www.somehost.com/cheats/PC/0001.php, it gets "internally?" redirected (the user doesn't see this) to a page, say, www.somehost.com/cheats/viewcheat.php?id=0001. Could anyone help? Thanks.

Burhan
12-17-2003, 08:45 AM
You need to search for mod_rewrite examples -- because that's what this requires.

I'm still getting the hang of mod_rewrite myself, but add this to your .htaccess file and give it a try

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/cheats/PC/(.*?)\.php$ viewcheat.php?id=$1 [L,QSA]
</IfModule>

kneuf
12-17-2003, 06:51 PM
fyrestrtr- thanks for your help, but it didn't work. It gives me a 403 error (is it suppossed to do that?). I'm searching for mod_rewrite examples as you said right at the moment.


I checked the mod_rewrite page at Apache, but they don't help. Anyone have an example they can post? Also, is there a way to check if it's enabled? I'm pretty sure it is, just want to check. Thanks.

Also, if I add Options +FollowSymlinks to the .htaccess file, it doesn't through an error, well, atleast not a 403 error.

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^/cheats/(.*?)\.php /cheats/viewcheat.php?id=$1 [R]

Now it throughs a 404 error, not found. But the pages are there. I have this in the /cheats/ directory.

kneuf
12-17-2003, 08:46 PM
I found one that works!

Options +FollowSymlinks
RewriteEngine on
RewriteBase /cheats/
RewriteRule ^view/(.*).php$ viewcheat.php?id=$1 [L]

thanks for your help.