-1

How would I go about having https://example.com/channels/[channel_name]/[video_id] appear in the address bar, but have my PHP script see https://example.com/channels?channel=[channel_name]&v=[video_id]? Given that [channel_name] and [video_id] would not be real directories.

1 Answers1

0

I was able to find a working example of what I was looking for here:

https://www.taniarascia.com/rewrite-query-string-to-path-with-htaccess/

The code in question appears as such:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?users/(.*?)/?$ /users.php?name=$1 [L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /users\.php\?name=([^\&\ ]+)
RewriteRule ^/?users\.php$ /users/%1? [L,R=301]

Where http://example.com/users/tania outputs as http://example.com/users.php?name=tania, which is the exact behavior I was looking for.

I understand the purpose of the first four lines. Could someone please elaborate on what the last two lines are for? I've tested this code over at https://htaccess.madewithlove.be/, and removing the last two lines seems to have no impact on the output.