Page 6 of 6
Re: Short / Tiny URL - how do you do it, and how can it work
Posted: Wed Jan 11, 2012 11:34 am
by simonmlewis
It isn't.
DirectoryIndex index.html index.htm index.php
order allow,deny
allow from all
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteRule ^categ/([0-9]+)/([^/]+)/ /index.php?page=categ&c=$1&cname=$2&menu=sub [L]
RewriteRule ^categ/([0-9]+)/([^/]+)/([0-9]+)/ /index.php?page=categ&c=$1&cname=$2&menu=sub&pagenum=$3 [L]
RewriteRule ^subcateg/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/ /index.php?page=subcateg&c=$1&cname=$2&s=$3&sname=$4&menu=sub [L]
RewriteRule ^product/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/ /index.php?page=product&c=$1&cname=$2&s=$3&sname=$4&menu=sub&product=$5&h=$6 [L]
RewriteRule ^([^/\.]+)/?$ index.php?page=$1&menu=home [L]
RewriteRule ^$ index.php?page=home&menu=home [L]
Re: Short / Tiny URL - how do you do it, and how can it work
Posted: Wed Jan 11, 2012 12:00 pm
by Eric!
You're going to drive yourself slowly insane doing it this way. I have to suggest again that you look back at the method I mentioned earlier using the 404 handler and a database.
Re: Short / Tiny URL - how do you do it, and how can it work
Posted: Wed Jan 11, 2012 12:04 pm
by simonmlewis
Sorry Eric, but absolutely no way can I do it that way.
This way works brilliantly, specially with hyphens.
I just need to be able to run the pagenum part (second rule), and then I am sorted!
Re: Short / Tiny URL - how do you do it, and how can it work
Posted: Wed Jan 11, 2012 12:32 pm
by Eric!
Why not? It's much cleaner and easier to maintain than 6+ lines of rewrite rules. Especially a year from now when you need to make changes to it and have to try to relearn what all those lines are doing all over again.
Re: Short / Tiny URL - how do you do it, and how can it work
Posted: Wed Jan 11, 2012 12:34 pm
by simonmlewis
These are all the lines I need.
Having spent two days writing all this and updating a massive web site, and with 'pickles' help - sorry no.
Just need to know what I am doing wrong with that pagenum example.
Re: Short / Tiny URL - how do you do it, and how can it work
Posted: Fri Jan 13, 2012 5:13 am
by simonmlewis
Can you not tag things on the end of a ShortUrl?
/PRODUCT/BIG-RED-SHIRT/&sn=yes
Here is my URL for a shirt. It's posted to an external site and then comes back with the "&sn=yes" which the page should see as stating something has been sent, and disables the form from being used again.
So how do you tag something on the end of a shorturl, and store it it a variable? I assumed it would take $sn as a variable and put "yes" into it.
But it doesn't.
Re: Short / Tiny URL - how do you do it, and how can it work
Posted: Fri Jan 13, 2012 6:13 pm
by Eric!
simonmlewis wrote:Can you not tag things on the end of a ShortUrl?
/PRODUCT/BIG-RED-SHIRT/&sn=yes
This is one of the problems with the rewrite technique. It is going to modify your URL's and in some cases drop data. I know I'm a broken record, but if you handle the short links with PHP code and a database you'll have easy 100% control. As a bonus you'll also see valid missing links show up, missing external links (which you can properly redirect), and monitor your short-URL traffic directly.
Perhaps you could modify your regex to pass on all the URL parameters to whatever page you are rewriting to by ignoring them, but I would have to spend a fair bit of time experimenting with it to fix your problem. I don't know off the top of my head.
Re: Short / Tiny URL - how do you do it, and how can it work
Posted: Mon Jan 16, 2012 10:11 am
by simonmlewis
Code: Select all
NameVirtualHost *
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:\xampp\phpMyAdmin\test1"
ServerName test1domain.local
<Directory "C:\xampp\phpMyAdmin\test1">
Order allow,deny
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:\xampp\phpMyAdmin\test2"
ServerName test2domain.local
<Directory "C:\xampp\phpMyAdmin\test2">
Order allow,deny
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
I've added test2 as a new virtual host, so I can have a second domain virtually hosted, but when I go to that domain, it just tries to take me to
http://www.test2domain.local....
It says "Server not found" so it's not a HTACCESS error.
What have I done wrong with this config file??
Re: Short / Tiny URL - how do you do it, and how can it work
Posted: Mon Jan 16, 2012 10:13 am
by pickle
That's both a new, and an Apache config question, so it should be asked in the System > Installation & Configuration forum.
Re: Short / Tiny URL - how do you do it, and how can it work
Posted: Mon Jan 16, 2012 11:08 am
by simonmlewis
Don't worry it was simple: the HOSTS file wasn't updated. How about this problem tho:
RewriteEngine On
RewriteRule ^categ/([0-9]+)/([^/]+) /index.php?page=categ&c=$1&cname=$2&menu=sub [L]
RewriteRule ^categ/page/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=categ&c=$1&cname=$2&menu=sub&pagenum=$3 [L]
RewriteRule ^subcateg/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=subcateg&c=$1&cname=$2&s=$3&sname=$4&menu=sub [L]
RewriteRule ^subcateg/page/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=subcateg&c=$1&cname=$2&s=$3&sname=$4&menu=sub&pagenum=$5 [L]
RewriteRule ^product/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=product&c=$1&cname=$2&s=$3&sname=$4&menu=sub&product=$5&h=$6 [L]
RewriteRule ^productsall/([0-9]+)/ /index.php?page=productsall&pagenum=$1/ [L]
RewriteRule ^sml/([^/]+) /index.php?page=a_login [L]
RewriteRule ^([^/\.]+)/?$ index.php?page=$1&menu=home [L]
RewriteRule ^$ index.php?page=home&menu=home [L]
I need the "sml/" rule to show index.php?page=a_login.
Even tho other /fred rules will show 'page=fred'. So basically that rule should override the other rule.
How do I do that?
Re: Short / Tiny URL - how do you do it, and how can it work
Posted: Wed Jan 18, 2012 4:48 am
by simonmlewis
I am not very confused.
If a link goes to
http://www.domain.co.uk/videos
It takes them to:
videos/?page=videos&menu=home
But if they go to /productsall, /contact, /faq .... etc, they all just show /productsall.... etc in the URL.
But /videos goes to that extended URL.
There are no rules in my HTACCESS that controls it. The problem is, when that page is up, and they click a link in the side menu that goes to /categ/55/fred..... it actually goes to /videos/categ/55 .....
Why would one page show a different url?
My HTACCESS file:
Code: Select all
DirectoryIndex index.html index.htm index.php
order allow,deny
allow from all
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteRule ^categ/([0-9]+)/([^/]+) /index.php?page=categ&c=$1&cname=$2&menu=sub [L]
RewriteRule ^categ/page/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=categ&c=$1&cname=$2&menu=sub&pagenum=$3 [L]
RewriteRule ^subcateg/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=subcateg&c=$1&cname=$2&s=$3&sname=$4&menu=sub [L]
RewriteRule ^subcateg/page/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=subcateg&c=$1&cname=$2&s=$3&sname=$4&menu=sub&pagenum=$5 [L]
RewriteRule ^product/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=product&c=$1&cname=$2&s=$3&sname=$4&menu=sub&product=$5&h=$6 [L]
RewriteRule ^productsall/([0-9]+)/ /index.php?page=productsall&pagenum=$1/ [L]
RewriteRule ^([^/\.]+)/?$ index.php?page=$1&menu=home [L]
RewriteRule ^$ index.php?page=home&menu=home [L]
Re: Short / Tiny URL - how do you do it, and how can it work
Posted: Wed Mar 23, 2016 6:17 am
by munkitkat
I thought the top one would take the page name, c number, cname word and put it all in, and add any hyphens where there are spaces, but it doesn't.
Re: Short / Tiny URL - how do you do it, and how can it work
Posted: Wed Mar 23, 2016 7:55 am
by Celauran
simonmlewis wrote:I thought the top one would take the page name, c number, cname word and put it all in, and add any hyphens where there are spaces, but it doesn't.
munkitkat wrote:I thought the top one would take the page name, c number, cname word and put it all in, and add any hyphens where there are spaces, but it doesn't.
Copypasta + thread necromancy = locked.