View Full Version : .htaccess
Hii
Second question i know, but google aint much help since it just slaps code in my face, and not sure what to do with it, so;
I have a website, and the url's are index.php?page=PAGEHERE
Now, how could i use modrewrite to make /page/PAGEHERE
Many Thanks
Luke
LMS16
03-01-2010, 05:11 PM
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^page/([a-z]+) http://site.com/index.php?page=$1 [NC]Editted it abit from http://corz.org/serv/tricks/htaccess2.php
Im not an expert but this looks like it could work :)
Hope this helps
Lew.
Trigs
03-01-2010, 09:40 PM
Sorry to hijack your thread but I was wondering how you could turn:
sitename.com/index.php?p=login
into:
sitename.com/login
LMS16
03-01-2010, 09:49 PM
Im guessing...
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([a-z]+) http://site.com/index.php?p=$1 [NC]
or sumit like tht... lol
Lew.
Blinger1
04-01-2010, 12:38 AM
Im guessing...
or sumit like tht... lol
Lew.
That would work.
http://www.addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet/
Invent
04-01-2010, 01:03 AM
Sorry to hijack your thread but I was wondering how you could turn:
sitename.com/index.php?p=login
into:
sitename.com/login
Just a few changes to the previous answer to allow uppercase letters/numbers/hyphens/underscores in the url as well (I think this will work anyway lol):
RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+) http://site.com/index.php?p=$1 [NC]
You could also just do a wildcard match but it doesn't make much difference.
Trigs
04-01-2010, 02:41 AM
What does the $1 mean/do?
Blinger1
04-01-2010, 04:00 AM
its the input after the = sign. So the $1 would equal "HELLO" if the url was "index.php?p=HELLO".
If there were two inputs (index.php?p=HELLO&x=HOWDY) $1 would equal HELLO and $2 would be HOWDY
worked perfectly thanks! +rep to all contributions
Jahova
06-01-2010, 10:43 AM
its the input after the = sign. So the $1 would equal "HELLO" if the url was "index.php?p=HELLO".
If there were two inputs (index.php?p=HELLO&x=HOWDY) $1 would equal HELLO and $2 would be HOWDY
Nice explanation for all, including the thread starter +REP.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.