[英]Redirect old URL to new URL in .htaccess
.htaccess 文件
# Apache configuration file (see httpd.apache.org/docs/current/mod/quickreference.html)
# disable directory listing
<IfModule mod_autoindex.c>
Options -Indexes
</IfModule>
# enable cool URL
<IfModule mod_rewrite.c>
RewriteEngine On
# RewriteBase /
# prevents files starting with dot to be viewed by browser
RewriteRule /\.|^\.(?!well-known/) - [F]
# front controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz|map)$ index.php [L]
</IfModule>
# enable gzip compression
<IfModule mod_deflate.c>
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript text/javascript application/javascript application/json
</IfModule>
</IfModule>
我使用 Nette FW,我想從 Nette\Application\Routers\SimpleRouter 遷移到酷 URL。
http://test.localhost/?action=add&presenter=Cr => http://test.localhost/cr/add
http://test.localhost/?id=303&action=edit&presenter=Cr => http://test.localhost/cr/edit/?id=30
如何將所有 URL 重定向到新 URL?
當您已經使用 netteRouter 時,您可以使用一種方式的路由器規則
即。 https://doc.nette.org/en/application/routing#toc-one-way-flag
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.