BrainPill Posted March 4, 2020 Share Posted March 4, 2020 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 comment Share on other sites More sharing options...
dsonesuk Posted March 4, 2020 Share Posted March 4, 2020 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 Link to comment Share on other sites More sharing options...
BrainPill Posted March 10, 2020 Author Share Posted March 10, 2020 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 comment Share on other sites More sharing options...
BrainPill Posted March 29, 2020 Author Share Posted March 29, 2020 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 comment Share on other sites More sharing options...
dsonesuk Posted March 29, 2020 Share Posted March 29, 2020 Yes! It should be, it just rewrites the url in the address bar while referring to original querystring url. Link to comment Share on other sites More sharing options...
BrainPill Posted April 1, 2020 Author Share Posted April 1, 2020 okay, if you say so. As I have tried numerous thing I start to suspect it might be due to other settings in for instance virtual hosts or httpd.conf Are there more things that should be heeded at? Link to comment Share on other sites More sharing options...
BrainPill Posted April 1, 2020 Author Share Posted April 1, 2020 On 3/30/2020 at 12:48 AM, dsonesuk said: Yes! It should be, it just rewrites the url in the address bar while referring to original querystring url. Can you give an example? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now