I have the following rules. It keeps on dumping the first level directory however.
The for[a-zA-Z0-9-_]/* keeps getting dumped. I need it to stay in the URL, but still submit everything following /gallery/ to the PHP file on the server. The goal here it to be able to customize this URL on the fly but still wind up at the same page. It's essentially a vanity URL directory for promotional purposes (which will also allow for easy identification using analytics trackers).
IE:
domain.com/for_jack/gallery/two
domain.com/gallery/two
Both of these should go to the same page, but the above URL keeps getting modified to look like the second URL. It should not be altered.
I'm aware of custom routes, however, I do not think what I want to achieve would work with it, at least not in the order I want and functionality I want.
- Code: Select all
Options +FollowSymlinks -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ "" [R=301,L,QSA]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule . - [L]
#for (CUSTOM TEXT) gallery.php
RewriteRule ^for[a-zA-Z0-9\-\_]*/gallery$ "$0/" [R=301,L,QSA]
RewriteRule ^for[a-zA-Z0-9\-\_]*/gallery/$ gallery.php [L,QSA]
RewriteRule ^for[a-zA-Z0-9\-\_]*/gallery/.*?([^\.\/]*)\.html$ gallery.php?pname=$1 [L,QSA]
RewriteRule ^for[a-zA-Z0-9\-\_]*/gallery/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ gallery.php?d=$1$2$3 [L,QSA]
RewriteRule ^for[a-zA-Z0-9\-\_]*/gallery/[^\.]*?([^/\.]*)/$ gallery.php?fname=$1 [L,QSA]
RewriteRule ^for[a-zA-Z0-9\-\_]*/gallery/[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]
#gallery.php
#NOTE: default operation below
RewriteRule ^gallery$ "$0/" [R=301,L,QSA]
RewriteRule ^gallery/$ gallery.php [L,QSA]
RewriteRule ^gallery/.*?([^\.\/]*)\.html$ gallery.php?pname=$1 [L,QSA]
RewriteRule ^gallery/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ gallery.php?d=$1$2$3 [L,QSA]
RewriteRule ^gallery/[^\.]*?([^/\.]*)/$ gallery.php?fname=$1 [L,QSA]
RewriteRule ^gallery/[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]
</IfModule>
The for[a-zA-Z0-9-_]/* keeps getting dumped. I need it to stay in the URL, but still submit everything following /gallery/ to the PHP file on the server. The goal here it to be able to customize this URL on the fly but still wind up at the same page. It's essentially a vanity URL directory for promotional purposes (which will also allow for easy identification using analytics trackers).
IE:
domain.com/for_jack/gallery/two
domain.com/gallery/two
Both of these should go to the same page, but the above URL keeps getting modified to look like the second URL. It should not be altered.
I'm aware of custom routes, however, I do not think what I want to achieve would work with it, at least not in the order I want and functionality I want.