Forum Moderators: phranque
Now we want to display different content based on the folder name.
For example /sunshine_3 or /sunshine_4
I thought it would be fairly simple to just snip off the _3 or _4 and turn it into an argument such as /sunshine/index.php?door=3
Here is the relevant part of my .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/([a-z0-9]+)_([0-9])$ [NC]
RewriteRule ^(.*)$ /$1/index.php?door=$2
I need the condition to fail for URLS that don't have the trailing _3 or _4 etc and that works fine, but the backreference to $1 always incudes the _3 or _4 and I get a page connot be found error.
How do I snip off the _3 or _4 so that $1 is only something like sunshine (not sunshine_3)
I have obsessed over this for about 5 days with no progress.
Thanks
John
All you need, based on what you posted, is something like this:
RewriteEngine on
RewriteRule ^([a-z0-9]+)_([0-9]+)$ /$1/index.php?door=$2 [NC,L]