elite_prodigy Posted May 5, 2008 Share Posted May 5, 2008 Can someone show me how to use mod_rewrite or link to a great tutorial? Thanks! --Elite Quote Link to comment Share on other sites More sharing options...
revraz Posted May 5, 2008 Share Posted May 5, 2008 google? Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted May 5, 2008 Author Share Posted May 5, 2008 I need to take a URL such as: http://www.somesite.come/RANDOM_TEXT and turn it into: http://www.somesite.com/site?siteName=RANDOM_TEXT Could someone show me how to do that? I want to give the appearance of individual directories without all the hassle as one "Super Mod" pointed out to me. (Thanks by the way) Thanks! --Elite Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 5, 2008 Share Posted May 5, 2008 The example you gave would be: <IfModule mod_rewrite.c> RewriteEngine On </IfModule> RewriteRule ^([a-zA-Z0-9]+)$ site?siteName=$1 RewriteRule ^([a-zA-Z0-9]+)/$ site?siteName=$1 That'll take any alphanumeric value request in the directory that you put this .htaccess in (no underscores, but I could add it....) and send it to site?siteName="whatever". Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted May 5, 2008 Author Share Posted May 5, 2008 Could you add underscores so it could do a url such as : http://www.somesite.come/happy_fields and turn it into: http://www.somesite.com/site?siteName=happy_fields Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 5, 2008 Share Posted May 5, 2008 <IfModule mod_rewrite.c> RewriteEngine On </IfModule> RewriteRule ^([a-zA-Z0-9_]+)$ site?siteName=$1 RewriteRule ^([a-zA-Z0-9_]+)/$ site?siteName=$1 Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted May 5, 2008 Author Share Posted May 5, 2008 Okay, when I click "Create New Directory" I enter .htaccess then I added <IfModule mod_rewrite.c> RewriteEngine On </IfModule> RewriteRule ^([a-zA-Z0-9_]+)$ site?siteName=$1 RewriteRule ^([a-zA-Z0-9_]+)/$ site?siteName=$1 Then I click "Save File" and the file never appears. But when I name it something like htaccess.htaccess the file appears. But I keep getting a page not found error. The .htaccess file is in my root directory in public HTML. So when I type an address like this: http://www.somesite.com/fun the Super Global $_get[] should recieve the siteName variable and recieve the value "fun" but I have a index.php file set up in the /site/ directory with <?php echo $_GET['site']; ?> But I never get to the index.php, just a cheap error page. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 5, 2008 Share Posted May 5, 2008 It's NOT a directory, it's a file. And it'll appear hidden if you use Linux because . in front of a filename means "hidden", but Apache REQUIRES it to be named .htaccess. Now. Just add a file ".htaccess" with that in it, and make sure you put the right page in....if it's index.php, use that....>_> Quote Link to comment Share on other sites More sharing options...
elite_prodigy Posted May 5, 2008 Author Share Posted May 5, 2008 The mod_rewrite should be able to handle several pages at once. Like I said, I want it to appear that they are in a separate directory. So users should be able to navigate through links and stuff without them ever seeing anything but their subdirectory. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 5, 2008 Share Posted May 5, 2008 You're going to need a hell of a lot of rewrite rules for that, unless you made a master page which took the GET from the mod_rewrite and included the page (your best bet, probably, but make sure it doesn't include anything sensitive). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.