TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   mod_rewrite correct? (http://www.talkphp.com/general/3123-mod_rewrite-correct.html)

CoryMathews 07-15-2008 03:00 AM

mod_rewrite correct?
 
I am having trouble with mod rewrite. I have looked at some tutorials and one of them stated to look for a module after running the phpinfo() thingy. I didnt have it, but after logging into godaddy (my host) they say all their linux hosting does. So I should. My question is should this work correcty or am I screwing something up. Im still really new at this and reg expressions arent my good buddy yet.

The rewrite should take a page called MoreInfo.php?p=22 into MoreInfo/p/22/

Code:

Options +FollowSymLinks
RewriteEngine on
RewriteRule MoreInfo/(.*)/(.*)/$ MoreInfo.php?$1=$2


delayedinsanity 07-15-2008 03:32 AM

That should work, but maybe give this a try?
Code:

Options +FollowSymLinks

RewriteEngine On
RewriteBase /

RewriteRule ^moreinfo/([A-Za-z]+)/([0-9]+)/?$ moreinfo.php?$1=$2 [L]


CoryMathews 07-16-2008 01:02 AM

Hum nope didn't work either must be the host. I will have to give them a call. Thanks delayed.

delayedinsanity 07-16-2008 02:24 AM

No problems... are you getting a 500 error when you attempt to add that to your .htaccess, or is it just not redirecting properly?
-m

CoryMathews 07-16-2008 02:28 AM

I just get a "No input file specified." thats it.

delayedinsanity 07-16-2008 03:31 AM

Hmmm, you sure that's not an error from your php script? Do you have it online somewhere for us to see?
-m

CoryMathews 07-16-2008 03:55 PM

No its not online but should be within the next week or 2. But I dont think it has to do with php because the file works perfectly fine on its own.

delayedinsanity 07-16-2008 04:25 PM

I was just thinking even if it wasn't online in the going live sense, maybe it was somewhere we could poke and prod at it in the test sense. Generally speaking if you have a rewrite rule in your .htaccess and you're not getting a 500, then mod_rewrite is enabled and working. I was thinking it might be one of those times we're both missing something simple... ;-) Is the full URL on your test something like; http://localhost/moreinfo.php?p=22 ?
-m

drewbee 07-16-2008 04:46 PM

What specifically is done to generate the 'no input file generated' error message? Is this an error message that comes from moreinfo.php when an invalid value for p= is specified?

CMellor 07-16-2008 07:07 PM

Hey, try:

Quote:

RewriteEngine On
RewriteRule ^p/([^/]*)/$ /MoreInfo.php?p=$1 [L]
Maybe add a base tag inside the <head> tag:

Code:

<base href="http://www.yoursite.com" />
and see if that helps. It once helped me.

CoryMathews 07-16-2008 07:26 PM

Quote:

Originally Posted by drewbee (Post 17124)
What specifically is done to generate the 'no input file generated' error message? Is this an error message that comes from moreinfo.php when an invalid value for p= is specified?

I go to moreinfo.php/p/11/ and thats what it says. and 11 should be there.

Ill try that out CMellor when i get a chance thanks.

drewbee 07-16-2008 07:29 PM

Quote:

Originally Posted by CoryMathews (Post 17129)
I go to moreinfo.php/p/11/ and thats what it says. and 11 should be there.

Ill try that out CMellor when i get a chance thanks.

Shouldn't you be going to moreinfo/p/11
typo?

Anyways, what I meant was does moreinfo.php generate that above error if you say go to the url /moreinfo.php?p=283234

CoryMathews 07-16-2008 11:14 PM

ye sorry i meant moreinfo/p/11 even if i use a number with no correct info I get the same No input file specified.

I have created a test page online to help with this. The link is http://www.osguide.net/test/test.php?$p=1

and this link should work
http://www.osguide.net/test/test/p/1/


Here is the .htaccess file

Code:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule /test/test/(.*)/(.*)/$ /test.php?$1=$2

and the php page

PHP Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<base href="http://www.osguide.net" />
</head>
<?php
if(is_numeric($_GET['p'])) {
        
$id $_GET['p'];
        echo 
$id;
}
?>
 This was a test.
<body>
</body>
</html>


delayedinsanity 07-17-2008 02:15 AM

Try adding;

Code:

Options -MultiViews
to the .htacess and see if that fixes it.
-m

CoryMathews 07-17-2008 02:17 AM

nope as you see now it is just not found all together.

drewbee 07-17-2008 01:26 PM

The following should work without a doubt... are you sure mod_rewrite is installed / active?

Code:

Options +FollowSymLinks
RewriteEngine on
RewriteRule moreinfo/(.*)/(.*)/$ /moreinfo.php?$1=$2

/moreinfo/p/123/


All times are GMT. The time now is 04:39 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0