monkeynote Posted August 8, 2007 Share Posted August 8, 2007 hello guys! i would like to ask on how can i create my user url friendly at Windows XP, Apache 2.2 and PHP 5.2? its something like this eg. http://sitename.com/login.php -> http://sitename.com/login/ http://sitename.com/redirect.php?accesscode=accesscode -> http://sitename.com/redirect/ http://sitename.com/control panel.php -> http://sitename.com/control panel/ how can i also link my stylesheet and images on it? should i put slash from the beginning of my image file? eg. "images/image.gif" -> "/images/image.gif" "scripts/style.css" -> "/scripts/style.css" i tried to place an .htaccess on the root website folder and mod_rewrite loaded according to <?php phpinfo();?> but it doesnt work this is what i put in .htaccess file Options -Indexes Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule ^([A-Za-z0-9-]+)/?$ /$ i tried to put http://sitename/test at my browser but the result is page cannot be found i hope that you can help me with my problem guys Quote Link to comment Share on other sites More sharing options...
hackerkts Posted August 9, 2007 Share Posted August 9, 2007 RewriteRule ^([a-zA-Z0-9-_ ]+)/?$ $1.php Put the full URL to your file. Quote Link to comment Share on other sites More sharing options...
monkeynote Posted August 10, 2007 Author Share Posted August 10, 2007 thanks for the reply i typed this in my .htaccess and restart Apache 2.2 Options -Indexes RewriteEngine On RewriteRule ^([a-zA-Z0-9-_ ]+)/?$ $1.php at first... it was not working when i type http://localhost:8888/test.php. it displays the normal page. but when i change Apache's httpd.conf file changing AllowOverride to ALL (default is NONE) <Directory "D:\PHPDirectory"> Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride All # # Controls who can get stuff from this server. # Order allow,deny Allow from all </Directory> when i restart my apache... i get an internal server error! wah!!!!!!!!!! :'( but when i put remarks on #RewriteRule ^([a-zA-Z0-9-_ ]+)/?$ $1.php it runs ok. Please help me with my problem :'( Quote Link to comment Share on other sites More sharing options...
hackerkts Posted August 10, 2007 Share Posted August 10, 2007 The Internal Server Error might be caused by not having mod rewrite module activate, wrong write rule or other problems.. Ok let's check on the mod rewrite module first, open up your http.conf Look for LoadModule rewrite_module modules/mod_rewrite.so Make sure it's not comment out. Now let's check for the rewrite rule, ok I think this causes the problem. Change it to RewriteRule ^([a-zA-Z0-9-_]+)/?$ $1.php Quote Link to comment Share on other sites More sharing options...
monkeynote Posted August 10, 2007 Author Share Posted August 10, 2007 wow! it works! hackerkts! you are indeed a hacker i have another question.... i created a page called testing.php but there are querystrings on it... how can i masked it like from this http://localhost:8080/testing.php?Name=monkeynote&Address=myaddress&remarks=cute to this http://localhost:8080/testing.php/monkeynote/myaddress/cute testing.php <?php echo $_GET["Name"] . "<br />"; echo $_GET["Address"] . "<br />"; echo $_GET["remarks"] . "<br />"; ?> promise it will be my last question thanks again! Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 10, 2007 Share Posted August 10, 2007 You'll have to edit your urls so they conform to your rewrite rules. Apache wont rewrite your hyperlinks for you. The urls you setup within .htaccess are only aliases. Quote Link to comment Share on other sites More sharing options...
monkeynote Posted August 10, 2007 Author Share Posted August 10, 2007 i got the solution to my problem (by using ^testing/^([a-zA-Z0-9-_]+)/^([a-zA-Z0-9-_]+)/^([a-zA-Z0-9-_]+))but there comes another problem... how about the space from my URL for example i have an Add User.php... how can i change it into http://localhost:8080/Add User/ i tried [:space:] but the URL appears like http://localhost:8080/Add%20User/ ??? also, im also having some problems with regards to redirection. for example... they are accessing the http://localhost:8080/controlpanel/ but the user is not authorized! so i redirect them to Unauthorized Page.php what happen is that, Unauthorized Page.php will be added to http://localhost:8080/controlpanel/ http://localhost:8080/controlpanel/Unauthorized Page.php mod_rewrite is not easy as i thought it would be ??? i hope that you can help me resolve this problem ??? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted August 10, 2007 Share Posted August 10, 2007 It is advided you should not use spaces within filenames on the web. You should use an underscore in replacement of spaces. Quote Link to comment Share on other sites More sharing options...
hackerkts Posted August 10, 2007 Share Posted August 10, 2007 As wildteen88 said, it's advise not to use space for your file, best would be replacing them with underscore or hyphen. Put the full URL on redirecting code. Quote Link to comment Share on other sites More sharing options...
monkeynote Posted August 11, 2007 Author Share Posted August 11, 2007 thanks for your advice masters i completely replaced space with underscore i also put the full URL to all my redirection page. thank you so much! you rock hackerkts and wildteen88 Quote Link to comment Share on other sites More sharing options...
hackerkts Posted August 11, 2007 Share Posted August 11, 2007 =D always glad to help out.. 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.