Doing pagination on a site through lazy load:
I would want to redirect
dir/546/index.html
if it does not exist
to
/dir/index.html
546/ is of any numeric value.
htaccess redirect not existing file (404) as 302 to another
Moderator: General Moderators
Re: htaccess redirect not existing file (404) as 302 to anot
Perhaps something like this?
Code: Select all
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/dir/([0-9]+)/?(index\.html)?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /dir/index.html [R=302,L,NC]Re: htaccess redirect not existing file (404) as 302 to anot
Yes, almost there, how might use /dir/ as wildcard for any directory name.
Thanks
Thanks
Re: htaccess redirect not existing file (404) as 302 to anot
Perhaps with another capture group? Replace ^/dir with the appropriate regex and use a lookback rather than a hardcoded value for the rewrite.