Home > Mobile >  Rewrite non-existing folder to be query without redirect
Rewrite non-existing folder to be query without redirect

Time:03-08

I need a way of getting example.com/159985870458322944/, or any other random 18-digit string, to be rewritten to example.com/?159985870458322944, where that string is a query key. It also needs to not change URL, so that the URL stays example.com/159985870458322944, but shows content that the index.php in the main directory (example.com/) gets thru the query.


I currently have this (not working)

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^/([0-9] )$ /?$1 [NC,P]
</IfModule>

Which does not work, as expected. I tried a lot of things I found, but didnt get any of the solutions working.

CodePudding user response:

There is no need to use P or proxy for this, just rewrite internally like this:

RewriteEngine On

RewriteRule ^(\d{18})/?$ /?$1 [L,QSA]
  • Related