Forum Moderators: phranque
I have a content managment system that gives too many directories and poor URL's and I am looking into learning some mod rewrites to fix this. Is there a downside to this? Does this cause unneccessary server load, or is it an efficient respectable way to fix this?
For me right now, this seems like it will be the easiest thing to use to change the URL structure to something more pleasant. Is this a good fix or do you recommend something else?
Thanks.
[edited by: CWebguy at 2:05 pm (utc) on Sep. 4, 2007]
What I am looking to do is different than a redirect (which is simply old URL to new updated URL). Because the pages I am using do not physically exist on the server (they are dynamically created) I don't think there is a need to have a physical page that I am linking to, just to change the URL that "goes/points to" to a certain file/page that the user has requested. Does this make sense or am I off track? (I am guessing that rewrites are different than redirects, correct?)
So in a sense you can rewrite an URL that looks like this
[mydomain.com...]
into something like
[mydomain.com...] (or whatever you like)
I guess my question is, is this acceptable to do using a mod rewrite in terms of effecieny, etc., or is there a better more reliable way?
[edited by: CWebguy at 2:40 pm (utc) on Sep. 4, 2007]
A rewrite takes the URL request from the browser and changes it into a server filepath to get the content from.
A redirect takes a request for one URL and sends a reply that forces the browser make a new request for a different URL.
.
Which of those two URLs do you want the user to see in their browser?
[edited by: g1smd at 3:03 pm (utc) on Sep. 4, 2007]
- a rewrite from http://(www.)domain.com/something/(value) URL to the server filepath /myscript.php?parameter=(value) to fetch the content from the real (and hidden) location.
- and you need a redirect from URL http://(www.)domain.com/myscript.php?parameter=(value) to new URL http://(www.)domain.com/something/(value) with [R=301] to prevent the content being accessed at the parameter-based URL.
The links on your pages will need to be in this format: http://www.domain.com/something/value.
[edited by: g1smd at 3:16 pm (utc) on Sep. 4, 2007]
The clean URLs should appear in the clickable links in the text of your content pages.
The mechanism to rewrite requests for clean URLs into parameter-based filenames to be fetched from the server, resides in some ModRewrite code located in the .htaccess file I expect.
Currently reading: [yourhtmlsource.com...] (seems to be what I need)
The hack comes with two files and these instructions:
How to install it?
------------------
Installation is simple:
1) Upload this two files to your Xoops root dir:
- loadpages.php
- xoops_shorturls.php
2) Modify your .htaccess file, the one you have in your Xoops root dir (if any)
and add the contents of the included .htaccess file. If you don't have one, just upload the one I provided.
3) In the Xoops root dir, there is a file named mainfile.php
Open it and add the following line just after the disclaimer (line 27 for
Xoops 2.06):
include "xoops_shorturls.php";
Save mainfile.php and upload it to your server.
IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT!
You have to edit the mainfile.php that is in your server, not the one that
originally comes with you Xoops, as this file is changed after installation.
After this, open your site. You should have ShortUrls working. Enjoy!
I am guessing that since this was written two years or so ago, maybe this guy never heard of mod rewrites, as the mod rewrites seem like they will accomplish the exact same thing, but maybe in a newer more effecient way (effecient is good!). What do you think?