Hi there PHP folk!
I'm an aspiring web developer and I have a question regarding urls and .htaccess. I'm working as a teacher at the moment but I want to get into development.
Here's the deal:
I want my hyperlinks to work like this:- href="domain.poo/page/"
but I want my server to see this:- "domain.poo/index.php?page=page"
And I want the URL to display the address bar like this (clients to see this):- "domain.poo/page/"
So correct me if I'm wrong (and please try to spell it out for me, I'm quite slow at times) but here's my current understanding:
- For optimising SEO: having URLS like 'domain.poo/page/?opt=value&etc=etc' is generally better!
- But if I'm picking up everything through my index page, it needs to be seeing 'index.php?page=page' to my server or my server needs to change it to this before my php scripts look at it... right?
As far as I understand, .htaccess can easily change a 'domain.com/index.php?page=page' to display as 'domain.com/page/'... but I for some reason REALLY want my hrefs to use the same formatting as that which the address bar displays...... so is it even possible to go from '.poo/page/' to '.poo/index.php?p=page' and then back to '.poo/page' for the users display and is there actually a SEO advantage to my preference or am I imagining things? Lol..
Thanks a heap and yes I realise this is probably the wrong forum for this question, I just have no idea which one it should go in >_<
- Lump
URLS and .htaccess
Moderator: General Moderators
-
visionary_tomato
- Forum Newbie
- Posts: 5
- Joined: Thu Sep 03, 2009 9:18 pm
Re: URLS and .htaccess
This seems like a dumb solution:
Each 'domain.poo/page/' folder has an index.php that does nothing but set the Header to 'index.php?page=page' and then my .htaccess changes the display url to 'domain.poo/page/'
Lol, that's so wrong, there must be something better than redirecting back to my index for every page change...
Each 'domain.poo/page/' folder has an index.php that does nothing but set the Header to 'index.php?page=page' and then my .htaccess changes the display url to 'domain.poo/page/'
Lol, that's so wrong, there must be something better than redirecting back to my index for every page change...
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: URLS and .htaccess
Moved to Installation and Configuration.
-
visionary_tomato
- Forum Newbie
- Posts: 5
- Joined: Thu Sep 03, 2009 9:18 pm
Re: URLS and .htaccess
thanks john
-
visionary_tomato
- Forum Newbie
- Posts: 5
- Joined: Thu Sep 03, 2009 9:18 pm
Re: URLS and .htaccess
So I was being dumb and misunderstood the implementation of .htaccess.
I can do what I aimed to achieve but a new problem has occured:
Is fine and dandy
But if I try to implement anything like:
It just doesn't provide the extra functionality...
I can't add to my $_GET array through the URL..
I just want this to work:
What am I doing wrong here?
I can do what I aimed to achieve but a new problem has occured:
Code: Select all
RewriteRule ^([^.*]+)/$ /TestProject/index.php?page=$1But if I try to implement anything like:
Code: Select all
RewriteRule ^([^.*]+)/(^.*)?$ /TestProject/index.php?page=$1&$2I can't add to my $_GET array through the URL..
I just want this to work:
Code: Select all
<a href="/TestProject/page/?key=value&key2=value2">Page with GET array</a>-
visionary_tomato
- Forum Newbie
- Posts: 5
- Joined: Thu Sep 03, 2009 9:18 pm
Re: URLS and .htaccess
Code: Select all
RewriteRule ^([A-Za-z0-9_-]+)/([^/.]+)*$ /TOMS/TestProject/index.php?page=$1&$2 [NC,L]