I have made the following HTAccess file for my personnal website (which is basically a portfolio).
# Error
ErrorDocument 401 /error.php?id=401
ErrorDocument 403 /error.php?id=403
ErrorDocument 404 /error.php?id=404
ErrorDocument 500 /error.php?id=500
# Enable URL rewriting
Options +FollowSymlinks
RewriteEngine on
RewriteOptions Inherit
# Url rewrite for assets
RewriteCond %{REQUEST_URI} !^/assets(/.*|)$ [NC]
RewriteCond %{REQUEST_URI} !^/gallery(/.*|)$ [NC]
RewriteRule ^.+$ / [R=302,L]
# Url rewrite for pages
RewriteRule ^home$ index.php
RewriteRule ^about$ about.php
RewriteRule ^gallery/(.+)$ gallery.php?id=$1
RewriteRule ^password/(.+)$ password.php?id=$1
RewriteRule ^private/(.+)$ private_gallery.php?id=$1
RewriteRule ^hidden/(.+)$ hidden_gallery.php?id=$1
RewriteRule ^download/(.+)$ download.php?id=$1
RewriteRule ^contact$ contact.php
This works great when I try to access these URLs directly through my web browser.
In my HTML and PHP code, I have these old URLS. I mean these URLs existed before I wrote the HTAccess file.
<a href="private_gallery.php?id=SomeGalleryId">Open this gallery</a>
When the user clicks on this URL, he is redirected to
/private_gallery.php?id=SomeGalleryId
and not to
/private/SomeGalleryId
Is there a way to change that without editing my PHP/HTML code ?