Jump to content

How to use Question Mark on Url after rewriting it?

- - - - -

  • Please log in to reply
8 replies to this topic

#1
MicroBoy

MicroBoy

    Newbie

  • Members
  • PipPip
  • 22 posts
How can I use Question Mark "?" on a URL after rewriting it via .htaccess, above are the examples I want to look like:

The url is:
http://webpage.com/read.php?id=342

I want to use it as:
http://webpage.com/?id=342


#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200

Quote

This would not really be a job for mod_rewrite, you can replace index.php with read.php and this would do what you have asked for you.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
MicroBoy

MicroBoy

    Newbie

  • Members
  • PipPip
  • 22 posts
index.php contains another code, I can't replace read.php with index.php

#4
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#
/? will always access index.php and no other file with normal configured web server. you can of course add the functionality of read.php into index.php and have something selecting which part to execute at which times...
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#5
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
Yes, for example if id is not defined, show the index. It is not too odd to do that.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#6
MicroBoy

MicroBoy

    Newbie

  • Members
  • PipPip
  • 22 posts
Aha thanks a lot for helping me.

#7
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
You are welcome!
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#8
Mark Wylde

Mark Wylde

    Learning Programmer

  • Members
  • PipPipPip
  • 46 posts
What you may be able to do is create a .htaccess file with the following#;
DirectoryIndex read.php

You could then put some code in your read.php file which says if there are no parameters in the query then redirect to the index.php file.

#9
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#
Yes you can, but what's the point doing that really? a rename would be more effective... There is no point changing the convention to have the main page called index.????. The most important useage for DirectoryIndex is to add more extentions for other program language like python etc...
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users