URL del método de obtención de php
demo.com/demo.php?name=45a
demo.com/demo.php/45¿Cómo puedo hacer esto usando el archivo .htaccess?
Primero necesita el módulo RewriteEngine en apache, agréguelo a su archivo .htaccess
RewriteEngine On # The following rule tells Apache that if the requested filename # exists, simply serve it. RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] # The following rewrites all other queries to index.php. The # condition ensures that if you are using Apache aliases to do # mass virtual hosting, the base path will be prepended to # allow proper resolution of the index.php file; it will work # in non-aliased environments as well, providing a safe, one-size # fits all solution. RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$ RewriteRule ^(.*) - [E=BASE:%1] RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L] # remove trailing slash # RewriteRule ^(.*)/$ /$1 [L,R=301] # To redirect all users to access the site WITHOUT the 'www.' prefix, # (http://www.example.com/... will be redirected to http://example.com/...) RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301] RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] Luego, debe tener un módulo de enrutador en php para manejar todas las URL que llegan a index.php
Algo como esto https://phprouter.com/