Forum Moderators: phranque

Message Too Old, No Replies

how to ADD index.php in just 1 URL

         

peoplesoft

9:20 am on Aug 18, 2009 (gmt 0)

10+ Year Member



Can any one help me in writing an htaccess condition such that as soon as the server receive request for this "particular" URL:

[mywebsite.com...]

The URL should automatically be "changed and redirected to":

[mywebsite.com...]

Basically adding "index.php" in the URL. The number of query string variables can increase or decrease.
It seems that the PHP framework I am using has an issue with using query string variables with segment based urls..

My existing htaccess file is as follows. This basically is to remove index.php from the URLs in rest of the website. don't know how to resolve the above problem..

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /CI-Directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /CI-Directory/index.php/$1 [L,QSA]
</IfModule>

jdMorgan

1:37 pm on Aug 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Several issues need to be clarified before you can make any progress.

The rule you posted does not 'remove index.php' at all. In fact, it *adds* index.php to the client-requested URL-path if that requested URL-path does not resolve to an existing file or directory, and passes control to the script at the resulting filepath.

mod_rewrite works as a client URL request arrives at your server, not as some sort of 'output filter'. Here, it is used to modify the *file* path associated with the client-requested *URL*.

Second, we'll need a much more precise description of the possible variations of the query string. For what query string names do you want to insert "index.php"? For what values of these query parameter names? Conversely, for what names and values should the "index.php" insertion *not* take place?

A thorough description along with several examples will help prevent you getting an incorrect answer and losing your potential helpers' attention by repeated 'No that's not quite right' posts.

Jim

peoplesoft

4:54 am on Aug 19, 2009 (gmt 0)

10+ Year Member



Thanks Jim for your reply..

You are right about the adding "index.php" path explanation.

Coming to the problem, The number of query string parameter can be one or more.. Since they would be coming in from a 3rd party system, I would not know "most" of their names as well (besides couple of them)...

With the above scenario, is it possible to achieve my desired outcome?

peoplesoft

3:47 pm on Aug 19, 2009 (gmt 0)

10+ Year Member



I am now focusing on an alternate solution to this problem.

[webmasterworld.com...]

I hope opening a new topic in my case (when I am looking for an altogether a different solution) do not count as violation of rules of the board. But please do let me know if it is and I will be more careful the next time.

StoutFiles

4:02 pm on Aug 19, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Since it's just for one page, couldn't you just go into the file and use an if-statement to change the variable values for that instance?

peoplesoft

4:15 pm on Aug 19, 2009 (gmt 0)

10+ Year Member



I am extreemly sorry StoutFiles but I could not understand your reply..
why and where do I need an if... statement to do what?

Extremely sorry.. just didn't get it.

StoutFiles

5:39 pm on Aug 19, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<?php

$param = $_GET['param'];
$param2 = $_GET['param2'];

if(($param == 0) && ($param2 == 4))
{
header ("Location: [mywebsite.com...]
}
?>

This would need to be before any html code. However, rereading your post I thought it was just for this these paramaters and not all of the parameters. So this probably won't be useful.

peoplesoft

5:57 pm on Aug 19, 2009 (gmt 0)

10+ Year Member



Yes this will not do..But appreciate your help..

g1smd

7:32 pm on Aug 19, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Be aware that using the HEADER directive in this way generates a 302 redirect.

You would likely need a 301 redirect here. That's an extra line of code.

jdMorgan

4:12 am on Aug 20, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Continued here: [webmasterworld.com...]