1

Some major websites have pages on their site indexed in ways like:

Amazon.com/%SEO%/dp/%product_serial_number%/

No matter what you put in the %SEO% section, it brings up the same page. So how do they reroute all requests regardless of path to a central script like that?

I'd like to use example.com/module/id#/command/ such as MyDomain.com/user/3/edit_profile/

As a secondary issue, is there a specific name for this technique?

I tried various things with .htaccess such as

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URL} !^(.*)?
RewriteRule ^(.*)$ http://example.com/?$1 [L,R=301]

but any changes there seem to change what is displayed in the address bar in a way that doesn't happen with the pretty URIs from these commercial sites. I want the central script to handle the page generation, but I don't want to alter what is displayed in the address bar.

I'm currently passing everything through GET, like example.com/?some/path/ But that is NOT a good solution.

Psudo
  • 11
  • 2
  • Does this answer your question? [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](https://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – CBroe Nov 21 '22 at 07:12
  • You want to implement an _internal_ rewriting rule, the attempt you posted implements an _external_ redirection instead. You first want to learn about the basics of request rewriting. Besides the reference the last comment referred to you also want to start reading the documentation of the rewriting module provided by apache: https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html – arkascha Nov 21 '22 at 12:17

0 Answers0