Jump to content

.htaccess rewrite rules?


Go to solution Solved by IceBurger,

Recommended Posts

Posted

I am using this .ntaccess rewrite rule to prettify the documentation URLs:

RewriteRule "^learn/(.+)$" "learn.php?page=$1"

This makes it so the URL "https://www.ultraengine.com/learn/Entity" gets treated as "https://www.ultraengine.com/learn?page=Entity".

However, if I have trailing arguments like "?lang=lua" they get omitted from the redirected URL. How can I add those into the rewrite rule? I want to use a URL like this:
https://www.ultraengine.com/learn/Entity?lang=lua

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

This works:

RewriteCond %{QUERY_STRING} ^lang=lua$
RewriteRule "^learn/(.+)$" "learn.php?page=$1&lang=lua"

RewriteCond %{QUERY_STRING} ^lang=cs
RewriteRule "^learn/(.+)$" "learn.php?page=$1&lang=cs"

RewriteCond %{QUERY_STRING} ^lang=cpp
RewriteRule "^learn/(.+)$" "learn.php?page=$1&lang=cpp"

RewriteRule "^learn/(.+)$" "learn.php?page=$1"

 

My job is to make tools you love, with the features you want, and performance you can't live without.

  • Solution
Posted

You could instead use the QSA flag, like this: 

RewriteRule "^learn/(.+)$" "learn.php?page=$1" [QSA]

  • Like 1

i now hate love C++

Beeeeeeeeeeeeeep~~This is a test of the emergency signature system~~Beeeeeeeeeeeeeep

RX 6800XT | i5-13600KF | 32GB DDR5 | 1440p is perfect

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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.

×
×
  • Create New...