Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
I have the following rules. It keeps on dumping the first level directory however.
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.
It did work for me okay. Try in another browser with clean cache/incognito mode.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
The mod_rewrite did not edit out the custom dir? I tried icognito mode, still clears out the custom directory.
cardmaverick wrote: The mod_rewrite did not edit out the custom dir? I tried icognito mode, still clears out the custom directory.

URL should not get changed at address bar at all. If you see it changed, then something is simply not working, because the idea is to see the full typed in url, but request goes to real location.
I saw it changed at first in Chrome, idk why. Then it worked in Edge and Chrome just fine.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
4 posts Page 1 of 1