Alexander Beninski
Alexander Beninski

Reputation: 817

.htaccess not rewriting the url

I have this problem: The administrator of the server says that he had rewrite_module enabled for the apache server but when I upload some test files to the server to test this functionality it does not work.

I have it enabled at localhost and it works perfectly fine there.

.htaccess content:

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

games.php content:

<?php 
$var = $_GET['id'];
echo $var;
?>

URLS:

localhost url:http://localhost/testing/games/123123
production url:http://mysite.com/test2/games/123123 

test2 is the folder that contains the files (.htaccess and games.php) What happens in production is that when i type this i get the page games.php but the id does not get echoed and query string is empty instead of getting the id 123123 which I provided.For localhost everything works fine and I get the id echoed. Maybe the administrator is wrong or what? Thank you in advance.

Upvotes: 1

Views: 2423

Answers (1)

itsjavi
itsjavi

Reputation: 2652

You are in subdirectories and you're telling the engine to rewrite when the request begins exactly with 'games'. You can try to remove the caret ^, or replace it with a slash / ... or add this after RewriteEngine on :

RewriteBase /testing/

in production:

RewriteBase /test2/

Or try:

RewriteEngine On
RewriteBase /test2/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^games/(.*)$ games.php?id=$1 [QSA,L]

Upvotes: 4

Related Questions