My current .htaccess file contains this code
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} .*jpg$|.*gif$|.*png$|.*mp3$ [NC]
RewriteRule (.*) /viewed.php?file=$1
I want to change it so it rewrites the URL to /viewed.php?file=$1 ($1 being file path) if the extension is not .php, but I don't know how to do that. (I found that code on another post and added my own extensions to the list)
If someone could link me to an explanation of how Rewrite Conditions work that would be great because I don't understand how to make them.
Rewrite all, if not .php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !^.*\.php$ [NC]
RewriteRule (.*) /viewed.php?file=$1 [L]
Documentation: http://httpd.apache.org/docs/current/mod/mod_rewrite.html
Learn RegEx: https://regexone.com/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.