Jump to content

Recommended Posts

Not quite, the site I am working on is complete Ajax based, and the problem I ran into is the back/forth button and bookmark will not function, so to correct that the server side is going to catch the "#" part and decide what to display, so sadly it has to be processed on the server side.

 

very weird...

but you can use JavaScript insted PHP...

use this code to print the url:

<script language="javascript" type="text/javascript"> 
document.write (document.location.href); 
</script> 

Link to comment
https://forums.phpfreaks.com/topic/165406-catch-php-url/#findComment-872351
Share on other sites

That's interesting, do you mind elaborate more on that more?

 

I'd recommend either using a $_GET var then, or using htaccess and modrewrite to just take whatever is after the slash

 

e.g. http://foo.com/additionalinfo

 

a combo of modrewrite and $_SERVER['REQUEST_URI'] should accomplish the same goal and actually look cleaner.

Link to comment
https://forums.phpfreaks.com/topic/165406-catch-php-url/#findComment-872371
Share on other sites

Something like this should do the trick.

 

Create a .htaccess file in the root directory of your website.  Within it's contents put the following:

 

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?pg=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?pg=$1

 

This code above does the following:

 

User accesses the page: http://foo.com/additionalinfo

The rewrite converts this page to: http://foo.com/?pg=additionalinfo

However the user doesn't see the conversion, it remains http://foo.com/additionalinfo to the user.

But PHP can now parse the variable by $_GET['pg'] (even though it doesn't appear to exist).

Link to comment
https://forums.phpfreaks.com/topic/165406-catch-php-url/#findComment-872380
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.