简体   繁体   中英

Use file in place of missing file with .htaccess (instead of redirect)

I am trying to use another file on the server in place of let say listing file zindex.php The file must function as if it actually existed in the said location. I was thinking I could do this with .htaccess however after scouring the net, I come up with no resources to do this. Is this even possible?

RewriteEngine On

RewriteCond $1 !^files
RewriteCond %{REQUEST_URI} custom_link_
RewriteRule .* zindex.php

This will execute zindex.php instead of index.php for the folder you put your .htaccess

RewriteEngine On

RewriteRule ^index.php$ zindex.php

# /index.php              will execute /zindex.php
# /index.php?query=string will execute /zindex.php //$_GET['query'] === 'string'
# /                       will execute /zindex.php
# /folder/index.php       will execute /folder/index.php

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM