.htaccess same url with or without /
I'm doing painful rewriting of many URLs on the website I'm currently working on, but I noticed a small problem:
RewriteRule ^domains/transfer$ ./cart.php?gid=11 [L,NC]
This line with navigation if I go to:
http://my-site/domains/transfer
But it won't work with a trailing /:
http://my-site/domains/transfer/
Is there any way to change the RewriteCode to accept any argument and go to the same page. It seems wasteful to have the same line twice to include '/'
Any help would be appreciated.
Greetings
source to share
Change the line as follows:
RewriteRule ^domains/transfer/?$ ./cart.php?gid=11 [L,NC]
The magic is here: /?
and this allows the previous character to be used, in which case the forward slash ( /
) is optional.
If you want something to appear after transfer
, then remove the dollar sign ( $
) that marks the end of a valid match.
source to share