steelmanronald06 Posted October 28, 2005 Share Posted October 28, 2005 Okay I need to run a normal URL into a full url rewrite. Any suggestions? An example would be: http://www.netgeekz.net/PHPSESSION?48942ed2032 to a url without that PHPSESSION?4803247ekwje (whatever the numbers were) However it also does it with my dirs like so: http://www.netgeekz.net/directory/PHPSESSION?849375dkjfew83 Of course my directories all have an index.php file, so that is not displayed if you navigate straight to the dir and no file. So any ideas? Also can you post why it is done like your example and a great tutorial on learning more about mod_rewrite? Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted October 30, 2005 Author Share Posted October 30, 2005 *bump* anyone? Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted October 31, 2005 Author Share Posted October 31, 2005 Help would be great! Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted November 1, 2005 Author Share Posted November 1, 2005 Anyone? Quote Link to comment Share on other sites More sharing options...
Cook Posted November 4, 2005 Share Posted November 4, 2005 Hey man, willing to help, but not sure I understand what you want to transform into what. What's the starting data, and what is it you want to have at the end of the rewrite? Can you elaborate a little? Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted November 4, 2005 Author Share Posted November 4, 2005 Well sometimes my session_start(); appeneds that PHPSESSID84890489374 to the end of my urls. I want mod_rewrite to hide that. I don't want them rewrote to anything. Is there a automatic way to do that or do I have to do each one manually? Also there are urls that are like: http://www.netgeekz.net/news/view_news.php...+Message+System I want to hide that end stuff. Make it go http://www.netgeekz.net/news/archive/30/ Anyway to do that? Also I would like for it to do it automatically because I add news and don't feel like editing anything to expand to the new news articel. Thanks. Quote Link to comment Share on other sites More sharing options...
Cook Posted November 4, 2005 Share Posted November 4, 2005 To turn the PHPSESSID rewrite off, you would have to edit your php.ini so that: session.use_cookies = On session.use_only_cookies = On url_rewriter.tags = None As to your second issue, something like this in your .htaccess should to the trick: RewriteEngine On RewriteRule ^/news/view_news\.php http://www.netgeekz.net/news/archive/30/ [R=301,L] Quote Link to comment Share on other sites More sharing options...
Cook Posted November 6, 2005 Share Posted November 6, 2005 So is it any good? Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted November 6, 2005 Author Share Posted November 6, 2005 Dosn't work Quote Link to comment Share on other sites More sharing options...
Guest footballkid4 Posted November 6, 2005 Share Posted November 6, 2005 I don't think you could use mod_rewrite to hide PHPSESSID, because how would mod_rewrite know what the SESSID is? It can't just guess it. That has to be changed in your php.ini Uncomment this line: ; session.use_only_cookies = 1 In php.ini, and set it to 0 Quote Link to comment Share on other sites More sharing options...
Cook Posted November 7, 2005 Share Posted November 7, 2005 Dosn't work 315463[/snapback] The PHPSESSID automatic appending to URLs should be turned off with what I gave you for your php.ini. Weird if it's not. It works just fine for me. Do you have control over your php.ini? Is your setup alright? You can try and change the settings at run-time with ini_set() otherwise . As to the mod_rewrite, this rule is fairly straightforward, am surprised it does not work either. Similarly to the above, do you have control over your .htaccess? Is your setup alright? Is mod_rewrite part of your Apache config (it is an optional module)? Quote Link to comment Share on other sites More sharing options...
Cook Posted November 7, 2005 Share Posted November 7, 2005 I don't think you could use mod_rewrite to hide PHPSESSID, because how would mod_rewrite know what the SESSID is? It can't just guess it. That has to be changed in your php.ini Uncomment this line: ; session.use_only_cookies = 1 In php.ini, and set it to 0 315535[/snapback] I agree with your php.ini change, as a matter of fact it is what I suggested two posts above. Now I think it would be possible to remove the PHPSESSID from the URL with mod_rewrite too with a rule looking something like this: RewriteEngine On RewriteRule (.*)&PHPSESSID $1 I haven't tried this, but I reckon it should work; However it relies on two assumptions left to be verified: 1- PHP rewrites the URL by appending the PHPSESSID at the very end of the URL; 2- PHP rewrites the URL before Apache does, so that PHPSESSID is in the URL at the time the above rule is run. Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted November 7, 2005 Author Share Posted November 7, 2005 I don't have php.ini setting access. i am on a huge hosting company. Quote Link to comment Share on other sites More sharing options...
neylitalo Posted November 7, 2005 Share Posted November 7, 2005 use ini_set at the start of your scripts [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--][span style=\"color:#0000BB\"]<? ini_set[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"session.use_cookies\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\"1\"[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]ini_set[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"session.use_only_cookies\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\"1\"[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]?>[/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] Quote Link to comment Share on other sites More sharing options...
Cook Posted November 7, 2005 Share Posted November 7, 2005 I don't have php.ini setting access. i am on a huge hosting company. 315603[/snapback] What about .htaccess? Does the rewrite rule work? Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted November 8, 2005 Author Share Posted November 8, 2005 No. I also tried Neylital's suggestion, and it was void as well. Quote Link to comment Share on other sites More sharing options...
Cook Posted November 8, 2005 Share Posted November 8, 2005 I think your next option is to contact your host's technical support... Quote Link to comment Share on other sites More sharing options...
neylitalo Posted November 8, 2005 Share Posted November 8, 2005 No. I also tried Neylital's suggestion, and it was void as well. 316066[/snapback] huh. I would have guessed it would work beautifully. Is there a setting in php.ini that says "You can't override this using ini_set"? I've been looking but can't find one... just an idea. Quote Link to comment Share on other sites More sharing options...
shoz Posted November 11, 2005 Share Posted November 11, 2005 Putting the following in a .htaccess file may help php_flag session.use_trans_sid off If you're using php5 you should also be able to use ini_set to change the value. php4 > 4.23 is supposedly unable to use ini_set to change that particular setting. ini_list PHP_INI_ALL in PHP <= 4.2.3. PHP_INI_PERDIR in PHP < 5. Available since PHP 4.0.3. Quote Link to comment Share on other sites More sharing options...
neylitalo Posted November 11, 2005 Share Posted November 11, 2005 php4 > 4.23 is supposedly unable to use ini_set to change that particular setting. PHP_INI_ALL in PHP <= 4.2.3. PHP_INI_PERDIR in PHP < 5. Available since PHP 4.0.3. 317307[/snapback] ah... didn't see that bit in there. I must have missed it. Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted November 11, 2005 Author Share Posted November 11, 2005 Talking to my host about the PHPSESSID. As to my other question...it didn't work. What I want is for the url: http://www.netgeekz.net/news.php?article=1 To be changed to http://www.netgeekz.net/news/1/ However I don't want to do that manually myself with each news post. I want every url to automatically be done. And example: http://www.netgeekz.net/news.php?article=1 Changes to http://www.netgeekz.net/news/1/ Automatically http://www.netgeekz.net/news.php?article=2 Changes to http://www.netgeekz.net/news/2/ Automatically And so on and so forth. Quote Link to comment Share on other sites More sharing options...
neylitalo Posted November 11, 2005 Share Posted November 11, 2005 I can give you a start - but not much else :X http://httpd.apache.org/docs/2.0/misc/rewriteguide.html Quote Link to comment Share on other sites More sharing options...
shoz Posted November 11, 2005 Share Posted November 11, 2005 As to my other question...it didn't work. What are you referring to? http://www.netgeekz.net/news.php?article=1 To be changed to http://www.netgeekz.net/news/1/ However I don't want to do that manually myself with each news post. I want every url to automatically be done. And example: http://www.netgeekz.net/news.php?article=1 Changes to http://www.netgeekz.net/news/1/ Automatically ModRewrite manipulates the request sent by the client. What you seem to be asking to do, is to manipulate your script's output similar to what PHP does when it adds the "session id" to the end of links etc. Unless you modify PHP or Apache itself, I don't know of a way to accomplish that. To be clear however, I'm assuming that when you say you don't want to do it manually. You mean you don't want to go through your scripts, modifying the places where you output links(<a href="">) EDIT: Actually I forgot about the output control functions that would allow you to modify the script's output Quote Link to comment Share on other sites More sharing options...
Cook Posted November 11, 2005 Share Posted November 11, 2005 http://www.netgeekz.net/news.php?article=1 Changes to http://www.netgeekz.net/news/1/ Automatically http://www.netgeekz.net/news.php?article=2 Changes to http://www.netgeekz.net/news/2/ Automatically And so on and so forth. 317319[/snapback] I've reworked my suggestion now that I understand better what you need. But again you'll have to have your host put this into an .htaccess for you if they don't allow you to do it yourself. RewriteEngine On RewriteRule ^/news\.php\?article=(.*) http://www.netgeekz.net/news/$1/ [R=301,L] Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted November 11, 2005 Author Share Posted November 11, 2005 That did the trick. Thanks all. 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.