Jump to content

Recommended Posts

Hey guys,

 

First off, I want to say i'm not sure if this was the right section, but it seemed most appropriate (if what i'm looking for is a PHP application, anyway)

 

The title was the most relevant way I could put it, but his is what i'm looking for:

 

An application which can convert your URL, so say for example a URL on my site was:

http://www.example.com/?thing=this

Then the application would convert the URL to:

http://www.example.com/thing/this

 

I'm sure i've seen this application advertised somewhere before, I just forgot what is was called!

 

Please respond, thanks ^_^

Link to comment
https://forums.phpfreaks.com/topic/202773-url-conversion/
Share on other sites

First flip your perspective on your head, the way your application should work is all links on your site should be change to be http://www.example.com/thing/this, then once this is done you use mod_rewrite to rewrite that style of url to the other style (http://www.example.com/?thing=this). Therefore you pages should be coded to work the way it probably currently does (i.e with http://www.example.com/?thing=this links), however all links on your page should be the other type. A simple example of how a RewriteRule...

 

RewriteRule ^([^/]+)/([^/]+)/?$ /?$1=$2

Link to comment
https://forums.phpfreaks.com/topic/202773-url-conversion/#findComment-1062743
Share on other sites

You will also need...

 

Options +FollowSymLinks
RewriteEngine on

 

Bare in mind this will forward ALL requests to your site to that page, this will likely screw up all css/images/js files on your site, so this is something to take into account also.

Link to comment
https://forums.phpfreaks.com/topic/202773-url-conversion/#findComment-1062748
Share on other sites

Oh, and on the redirection - to avoid image/js/css collision, I could just redirect from a URL which doesnt exist, such as site.com/site/WHATEVERHERE which redirects to site.com/site.php?s=WHATEVERHERE

 

This will stopp the collision with css/js/imgs won't it? Since the directory /site doesn't actually exist, it's just what the users will type

Link to comment
https://forums.phpfreaks.com/topic/202773-url-conversion/#findComment-1062752
Share on other sites

Okay, but it seems to not work.

 

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule site/^(.*)$ /site.php?s=$1

 

http://site.com/site/hi

 

Not Found

The requested URL /site/hi was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Link to comment
https://forums.phpfreaks.com/topic/202773-url-conversion/#findComment-1062763
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.