manix Posted August 5, 2011 Share Posted August 5, 2011 Hello, How do I turn "site.com/user.php?id=$userid" into site.com/user=$userid I used "$userd" to describe that this is a variable value Link to comment https://forums.phpfreaks.com/topic/243971-htaccess/ Share on other sites More sharing options...
Maq Posted August 5, 2011 Share Posted August 5, 2011 You can do it with mod_rewrite, I'll move it there. Link to comment https://forums.phpfreaks.com/topic/243971-htaccess/#findComment-1252776 Share on other sites More sharing options...
manix Posted August 5, 2011 Author Share Posted August 5, 2011 Thanks for moving it, Yes I know this is how it's done but I can't manage to complete the task because I can't really get how the replacing works, all I get is that ^ starts and $ ends the search O,o Link to comment https://forums.phpfreaks.com/topic/243971-htaccess/#findComment-1252778 Share on other sites More sharing options...
requinix Posted August 5, 2011 Share Posted August 5, 2011 Check out the Cheat Sheet sticky. Link to comment https://forums.phpfreaks.com/topic/243971-htaccess/#findComment-1252808 Share on other sites More sharing options...
manix Posted August 5, 2011 Author Share Posted August 5, 2011 that was some magnificently awesome article, thanks man! Link to comment https://forums.phpfreaks.com/topic/243971-htaccess/#findComment-1252829 Share on other sites More sharing options...
Maq Posted August 5, 2011 Share Posted August 5, 2011 Hmm seems like this link is broken. I'll try and see if there is a updated one. http://www.ilovejackdaniels.com/mod_rewrite_cheat_sheet.png Link to comment https://forums.phpfreaks.com/topic/243971-htaccess/#findComment-1252835 Share on other sites More sharing options...
manix Posted August 5, 2011 Author Share Posted August 5, 2011 it's all working great, even better than I expected, I just have this one last (i hope) issue it wont let me have this (idk the word in english, would appreciate if someone mentions it too ) ":" in here >> RewriteRule ^user:([A-Za-z0-9-]+)/?$ user.php?user=$1 [L,NS] Link to comment https://forums.phpfreaks.com/topic/243971-htaccess/#findComment-1252843 Share on other sites More sharing options...
Maq Posted August 5, 2011 Share Posted August 5, 2011 idk the word in english, would appreciate if someone mentions it too Colon. Link to comment https://forums.phpfreaks.com/topic/243971-htaccess/#findComment-1252845 Share on other sites More sharing options...
manix Posted August 5, 2011 Author Share Posted August 5, 2011 yeah, thanks. What a shame.. ;x it wont let me have colon in here >> RewriteRule ^user:([A-Za-z0-9-]+)/?$ user.php?user=$1 [L,NS] Link to comment https://forums.phpfreaks.com/topic/243971-htaccess/#findComment-1252846 Share on other sites More sharing options...
requinix Posted August 5, 2011 Share Posted August 5, 2011 I've seen the issue before but I don't remember why. I do remember that the answer was basically to not use colons in the URL. How about an equals sign? A hyphen? Link to comment https://forums.phpfreaks.com/topic/243971-htaccess/#findComment-1252854 Share on other sites More sharing options...
manix Posted August 5, 2011 Author Share Posted August 5, 2011 Well I don't really care what I'll use I'm just curious why it wont let me, and by the way the most popular video portal in my country's url uses colon, like website.com/play:videoid and this seems pretty cool now when I can not achieve it Link to comment https://forums.phpfreaks.com/topic/243971-htaccess/#findComment-1252872 Share on other sites More sharing options...
requinix Posted August 5, 2011 Share Posted August 5, 2011 Some quick Googling (I suggest you try it) brings up the possibility that it doesn't work on Apache on Windows because colons aren't allowed in filenames. Sounds logical. Link to comment https://forums.phpfreaks.com/topic/243971-htaccess/#findComment-1252897 Share on other sites More sharing options...
manix Posted August 5, 2011 Author Share Posted August 5, 2011 yup. I tried googling, otherwise I wouldn't post here. Thanks ! Link to comment https://forums.phpfreaks.com/topic/243971-htaccess/#findComment-1252902 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.