FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


.htaccess rewrite not working - any suggestions





metalfreek
I am using php and I want my URL structure like mywebsite.com/user for a user profile page. I tried this in .htaccess but after adding this, I always get Internal server error message.

My .htaccess content

RewriteEngine On
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(.*)$ /profile.php?username=$1

I am using Frihost as hosting. Help me out here guys. I am running out of ideas.
jmraker
I have something simular in a working .htaccess file...

You could try using curly brackets { instead of (

Code:
RewriteCond %{REQUEST_FILENAME} !-d

instead of
Code:
RewriteCond %(REQUEST_FILENAME) !-d


If that doesn't work you can try
Code:
RewriteRule ^(.*)$ /profile.php [L]

and in profile.php use
$_SERVER['REDIRECT_URL'] to get the original url that matched the rewrite rule.
metalfreek
jmraker wrote:
I have something simular in a working .htaccess file...

You could try using curly brackets { instead of (

Code:
RewriteCond %{REQUEST_FILENAME} !-d

instead of
Code:
RewriteCond %(REQUEST_FILENAME) !-d


If that doesn't work you can try
Code:
RewriteRule ^(.*)$ /profile.php [L]

and in profile.php use
$_SERVER['REDIRECT_URL'] to get the original url that matched the rewrite rule.


Thanks man. It worked for me. Here is the working .htaccess code for future reference

Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /profile.php?username=$1
Zackster
Something I always do is set the rewritebase:

Code:
RewriteBase /


This will solve some future unexpected problems that might occur. A server on your PC will differ hugely from an actual server. Well that just my experience.
Related topics
Working with a Designer
.htaccess instead of mod_rewrite
IP Address Banning ( Not using .htaccess)
.htaccess NOT WORKING
php (phpBB) help
Please Please give me some understanding
Rewrite Rule in .htaccess
Frihost time. -Marketplace-
How do other sites do what I want to do?
.htaccess SEF urls
rewrite rule htaccess
Mod Rewrite .htaccess
.htaccess rewrite
hide folder or files in url bar
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.