0

In my .htaccess file I've got a rule that strips the .php:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

So, /mydomain.com/page.php becomes /mydomain.com/page/ - Which works fine.

Now I'm trying to achieve something similar with query strings, where:

/mydomain.com/page.php?variable=value becomes /mydomain/page/value/

I've tried numerous methods and the best I can get is /mydomain/page/?variable=value

1 Answer 1

1

Your second rule is

RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php

You can change this to rewrite to a query param like this:

RewriteRule ^([^/]+)/([^/]+)/$ /$1.php?variable=$2

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.