Jump to content

URL conversion


Joshua4550

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.