Question

back again (You'll be glad to know I'm slowly making progress with all your help!) reached another snag and this time it's with .htaccess...

I am attempting to make it so that you can access user profiles like this... site.co.uk/'username' at the moment I have changed the code in my profile page to look like this...

 <?php 
include 'core/init.php';

if (isset($_GET['username']) === true && empty($_GET['username']) === false) {
$username   = $_GET['username'];

echo $username;
} else {
header('Location: index.php');
exit();
}

?>  

I attempted to add the following code to my .htaccess file to make this work:

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

Problem is as soon as I try to access my website, it sends me to an error page for the webhost provider (000webhost.com). No matter what I've tried I just can't get it working? Any little edit takes the entire website down? Here is how the original .htaccess code looks already uploaded on the server before you upload the website (works fine with this):

<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.htm user_signup.php user_default_page.php index.html index.shtml index.php
</IfModule>

<IfModule mod_deflate.c> 
SetOutputFilter DEFLATE 
</ifmodule> 
<IfModule mod_headers.c>
<FilesMatch "\.(css|js|jpg|jpeg|gif|png|bmp)$">
    Header set Cache-Control "max-age=604800, private, must-revalidate" 
</FilesMatch>
Header set Vary "Accept-Encoding"
</ifmodule>


IndexIgnore *
<FilesMatch .htaccess>
Order allow,deny
Deny from all
Satisfy All 
</FilesMatch> 

<IfModule mod_rewrite.c>
RewriteEngine On 
RewriteCond %{QUERY_STRING} ^thankyou-page=([0-9]*)$ 
RewriteRule ^(.*)$ affilates_redirect.php [L]
</IfModule>

ErrorDocument 404 /404.php

Would really appreciate any help or advice! Thanks gurus!

Was it helpful?

Solution

These aren't valid rules

RewriteCond %{REQUEST_FILENAME} !=f
RewriteCond %{REQUEST_FILENAME} !=d

In this case f and d are flags and should start with a dash (-) not an equals sign (=).

Try changing them to:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top