I have this URL:
localhost:1001/project/index.html
And if I write this URL:
localhost:1001/project/index.html.twig
I want it to be masked to the first one ( localhost:1001/project.index.html
) but the URL processed must be the second one (don't know if it is possible).
I have tried all of this but I think all is wrong in my .htaccess
in project folder root, because nothing worked as I want:
a)
RedirectMatch 302 /project/index.html.twig /project/index.html
b)
RedirectMatch 301 /project/index.html.twig /project/index.html
c)
RewriteCond %{HTTP_HOST} ^/project/index.html.twig$ [NC]
RewriteRule /project/index.html [R=301,L]
COMMENTS
Process I want to obtain:
localhost:1001/project/index.html.twig
.htaccess
to convert that URL in the browser to localhost:1001/project/index.html
and see that URL in the browser localhost:1001/project/index.html.twig
This probably is what you are looking for if you want an external redirection:
RewriteEngine on
RewriteRule ^/?project/index\.html$ /project/index.html.trig [R=301]
RewriteRule ^/?project/index\.html\.twig$ /project/index.html [END]
In case you want an internal rewrite use that variant:
RewriteEngine on
RewriteRule ^/?project/index\.html\.twig$ /project/index.html [R=301]
RewriteRule ^/?project/index\.html$ /project/index.html.trig [END]
These rules should work likewise, in the http servers host configuration or in a dynamic configuration file (".htaccess" style file). You should definitely prefer the first option if you have access to it. If you need to use a dynamic configuration file then take care that it's interpretation is enabled at all and that it is located in the host's DOCUMENT_ROOT
folder.
In case you receive a server internal error (http status 500) using that rule chances are that you operate an old version of the apache http server. You will find a definite hint on an unknown [END]
flag in the http servers error log file in that case. Try using the older [L]
flag in that case, it will probably work the same here, though that depends on your setup.
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.