| JREF Homepage | Swift Blog | Events Calendar | $1 Million Paranormal Challenge | The Amaz!ng Meeting | Useful Links | Support Us |
![]() |
|
|
|
|||||||
| 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. |
|
|
#1 |
|
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. |
|
|
|
|
#2 |
|
Graduate Poster
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 |
|
|
|
|
|
#3 |
|
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. |
|
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|