Jump to content

How to get _REQUEST // _GET value with no file name


saariko

Recommended Posts

Hi,

What I am trying to do is transfer a _GET value to a default page, with as little URL naming as possible.

 

I'll explain - I have a processing php file/page that gets values from the _GET of the URL. The output is a new redirect to an alternate page. The processing function takes the value: id=XXX, and according to the id  redirects to XXX.

 

What I am trying to do is:

1. not give the file name in the original address - succesfully done that by editing .htaccess DirectoryIndex directive.

2. transfer only 1 value in the calling address.

 

So, if I call: www.site.com/a/[VALUE]  I want my processing page to read the [VALUE]  How can I do that?

 

First trying to echo the vlaue (if I will be able to do that I am ok)

<?php
// Get a file into an array.  In this example we'll go through HTTP to get
// the HTML source of a URL.

        foreach($_REQUEST as $key => $value){
                echo $value . "<br>";//You can for mat with HTML right here too
        }

 

Link to comment
Share on other sites

Cheers for the quick reply, here are the settings I am trying on my .htaccess

 

  RewriteBase /
  Rewritecond %{REQUEST_URI} !(^/a/*$) [NC]
  RewriteRule a/([0-9]+) /a/p.php?id=$1 [L]

 

I am trying to rewrite from: http://www.domain.com/a/VALUE 

to

http://www.domain.com/a/p.php?id=VALUE

 

however, it's not working. any ideas why ?

 

appreciate your help

Link to comment
Share on other sites

***

 

First, if anyone can move this to the MOR_REWRITE, i will appreciate it. I don't want to double post.

 

http://www.phpfreaks.com/forums/index.php/board,50.0.html

 

***

 

 

Ok, I am still strugling on this, here is my last conf.

 

My .htaccess is located on my root, and with the following tries (they are accesssed, because if for instance I will rewrite to: www.cnn.com  it will work)

 

  RewriteBase /
  RewriteRule ^a/(.*)$ a/p.php?id=$1 [R=301,L]

 

 #  RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
#  RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]
#  RewriteRule ^a/([A-Za-z0-9-]+)?$ a/p.php?id=$1 [NC]

 

Do I need to move the .htaccess to my /a/ directory? and change the rules?

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.