JREF Homepage Swift Blog Events Calendar $1 Million Paranormal Challenge The Amaz!ng Meeting Useful Links Support Us
James Randi Educational Foundation JREF Forum
Forum Index Register Members List Events Mark Forums Read Help

Go Back   JREF Forum » General Topics » Computers and the Internet
Click Here To Donate

Notices


Welcome to the JREF Forum, where we discuss skepticism, critical thinking, the paranormal and science in a friendly but lively way. You are currently viewing the forum as a guest, which means you are missing out on discussing matters that are of interest to you. Please consider registering so you can gain full use of the forum features and interact with other Members. Registration is simple, fast and free! Click here to register today.

Reply
Old 20th July 2011, 12:34 AM   #1
jmontecillo01
Thinker
 
Join Date: Oct 2006
Posts: 192
php url redirection

I am not sure though if the requirement I have is called "redirection". This is what the problem is all about.

If I type in www.mysite/index.php/searchitem, the page index.php will be executed with:

$_SERVER['REQUEST_URI']
"/index.php/searchitem"

$_SERVER['SCRIPT_NAME']
"/index.php"

But if I request www.mysite/searchitem, index.php will be executed with

$_SERVER['REQUEST_URI']
"/searchitem"

$_SERVER['SCRIPT_NAME']
"/index.php"

I then simply match 'REQUEST_URI' and 'SCRIPT_NAME' to figure out what is being requested.

This url format works under apache by adding in .htaccess:
RewriteRule . index.php

I could not make the second example (the one without index.php) work under IIS. It keeps on telling me that the path/page I requested does not exists.

In fact $_SERVER['REQUEST_URI'] is not provided under IIS. I had to check if $SERVER['REQUEST_URI'] is set. and if not, then I set in manually.

Thanks in advance for any advice.
jmontecillo01 is offline   Quote this post in a PM   Nominate this post for this month's language award Copy a direct link to this post Reply With Quote Back to Top
Old 20th July 2011, 01:06 AM   #2
erlando
Graduate Poster
 
erlando's Avatar
 
Join Date: Apr 2007
Location: Denmark
Posts: 1,008
Try adding a '/' :

RewriteRule . /index.php

ETA: You'll probably want to add QSA as a flag to that
__________________
"If it can grow, it can evolve" - Eugenie Scott, Ph.D Creationism disproved?
Evolution IS a blind watchmaker

Last edited by erlando; 20th July 2011 at 01:11 AM.
erlando is offline   Quote this post in a PM   Nominate this post for this month's language award Copy a direct link to this post Reply With Quote Back to Top
Old 20th July 2011, 02:37 AM   #3
jmontecillo01
Thinker
 
Join Date: Oct 2006
Posts: 192
Thanks,

It works now. The only thing is for apache, the file .htaccess is used while in IIS, the file is web.config.

Just in case others are interested,

(Apache) .htaccess:

Options +FollowSymLinks
IndexIgnore */*
# Turn on the RewriteEngine
RewriteEngine On
# Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

for IIS - web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<identity impersonate="false" />
</system.web>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{URL}" pattern="^/webitor/api.*$" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="webitor/webitor_api.php" appendQueryString="true" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{URL}" pattern="^/webitor/api.*$" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
<directoryBrowse enabled="false" />
</system.webServer>
</configuration>

ETA: don't know why some words are suppressed by rule 2.

Last edited by jmontecillo01; 20th July 2011 at 02:39 AM.
jmontecillo01 is offline   Quote this post in a PM   Nominate this post for this month's language award Copy a direct link to this post Reply With Quote Back to Top
Reply

JREF Forum » General Topics » Computers and the Internet

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -7. The time now is 08:43 AM.
Powered by vBulletin. Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
© 2001-2012, James Randi Educational Foundation. All Rights Reserved.

Disclaimer: Messages posted in the Forum are solely the opinion of their authors.