Jump to content

$_GET does not process params due to htaccess problem


Recommended Posts

 

I have a htaccess file. The first lines (#preceding code) work well
From #problem code I get problems.

The idea is a php menu set up (simulation) with an < a href ""> link
where all the query code is sent back to the page while the URL
only shows the index6 (as a directory) 
This worked while using a form with $_GET

But for the a href link it does not work properly what happens is that the $_GET input is not
parsed by PHP anymore. The URL though stays 'clean' or 'tidy' or whatever; in any case without 
the query part.

 

index6.php page:

<?php
//var_dump($_SERVER);

var_dump($_SERVER['HTTP_HOST']);


?>
<html>
<body style=" ">
<div style="margin-left: 600px; margin-top: 200px; width: 800px; height: 400px; border: 2px solid brown;">
<br><br>

<p style="font-size: 20px;">
TEST
</p><br><br>
Index page. Execute at a virtual (test) host 
<br><br>
 
<br><br>
<a href="http://<?php echo $_SERVER['HTTP_HOST'] ?>/index6.php?mvalu=home">Home</a>

<?php 

if(isset($_GET['mvalu'])) {
	
	var_dump($_GET['mvalu']);
	
}

?>
</div>
</body>
</html>

 

the .htaccess file

 

##################
# preceding code 

RewriteEngine On
RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteRule ^ /%1 [NC,L,R]

 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/$ /$1 [R=301,L]

#######################################
# problem code from here :
 
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/index6.php [NC]
RewriteCond %{QUERY_STRING} \bmvalu=home\b [NC]
RewriteRule ^index6\.php$ /index6/%1/? [NC,R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^index6/(\bmvalu=home\b)/?$ /index6.php/$1 [QSA,L]


 

I hope someone here can help me with solving how to get a tidy url and processing the $_GET data correct.

 

 

Link to post
Share on other sites

Ok well I removed the code but this did not give any other result.

I use $_GET to process a variable. 

When I test this in an html form I see the output I want.

When I use $_GET in the same script but with a link it does not work.

(btw you say that using RewriteEngine On and RewriteBase / in this way is not needed, but it worked in the form script for me)

Is there a reason that apache processes this different and how can I change these settings?

Link to post
Share on other sites
  • 3 weeks later...
On 3/4/2020 at 2:44 PM, dsonesuk said:

You only use this once at beginning of htaccess file

RewriteEngine On

then

RewriteBase /

The above determines what directory the following mod rewrites will be working to

 

Is it possible to still execute the $_GET php code and have a clean url ?

 

I find it EXTREMELY hard to solve my problem written in the OP.

Link to post
Share on other sites

Join the conversation

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

Guest
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.

Loading...
×
×
  • Create New...