Jump to content

Recommended Posts

Posted

Hi, I'm trying to make a rule on an .htaccess file, but for some reason the rule is not working. First the rule is:

 

>RewriteEngine On
RewriteRule ^test/(.*)/(.*).php /test.php?var1=$1&var2=$2

 

The script is called test.php and it is:

 

><?php
echo "var1 is: ";
echo $_GET['var1'];
echo "<br />";

echo "var2 is: ";
echo $_GET['var2'];

?>

 

I chmod the .htaccess to 644 (-rw-r--r--) because some tutorial on the web suggested it. The .htaccess file is in a subdirectory. Does it have to be in the home directory? The htaccess file and the test.php and in the same directory and when I call the the file I call it relative to where the .htaccess file is.

 

I'm confused. Can anyone help?

 

Thanks,

Sandro

Posted

Ok, so I got it to work by changing the directory and adding [R] to the end, but now the url changes to the old format. I would like the url to stay like /test/thisis/atest.php instead of /test.php?var1=thisis&var2=atest

 

 

>RewriteEngine On
RewriteRule ^test/(.*)/(.*).php /polidiggs/testbed/test.php?var1=$1&var2=$2 [R]

Posted

Sometimes you figure things out after you ask people questions. This is one of those times. I needed to add the [L] flag instead of the [R] flag.

 

Sandro

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...