简体   繁体   中英

Redirect old URL to new URL in .htaccess

.htaccess file

# 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>

I use Nette FW, I want to migrate from Nette\Application\Routers\SimpleRouter to cool URLs.

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

How can I redirect all URLs to new URL?

when you already use netteRouter, you can use there one way router rules

viz. https://doc.nette.org/en/application/routing#toc-one-way-flag

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