Home » Php » .htaccess – htaccess redirect requests to index.php with former paths as query string

.htaccess – htaccess redirect requests to index.php with former paths as query string

Posted by: admin February 25, 2020 Leave a comment

Questions:

i am trying to use a htaccess file to redirect (not rewrite) all requests (except css, js and images) to my index.php file and pass the former paths as query string.

example.de/path/test -> example.de?path1=path&path2=test

I have already looked here for some answers, but they all used rewrite

Thanks for any help

How to&Answers:

See if this helps:

Original URL:

http://www.example.com/index.php?id=100

Desired destination URL:

http://www.example.com/100/

.htaccess syntax:

RewriteEngine On
RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA]

You can explore further over here:

https://gist.github.com/ScottPhillips/1721489