Existing movable type plugin that does URL shortening and redirection? - movabletype

We send out a newsletter that has URLs in it. Rather than having foreign URLs directly, they all come to our website and then redirect to the outside world.
Right now the redirects are all done with HTML files. My goal is to have them all done with redirects in the .htaccess file. So I want to have the person who is entering all of this data enter it all through the movable type GUI.
My questions:
Is there is plug-in for movable type that already does this?
If not, is there a good template for creating a movable type that allows one to records in the MySQL database?
Thanks.

This could be done in the standard Entry interface in MT. Just dedicate a blog for these redirects. You could make the EntryTitle the redirect and have the EntryBody be the full URL (or use Custom Fields). Then just create an .htaccess template that loops through all the entries.
<mt:Entries lastn="0">
Redirect /<mt:EntryTitle dirify="-"> <mt:EntryBody>
</mt:Entries>

The way I would do this is to create a custom field for the outside URL.
Then I would populate the .htaccess file with something like:
Redirect /
In the above coding, I'm looping through the latest 999 entries and I'm checking if the custom field with the tag 'EntryDataMyCustomField' is filled out.
If it is filled out, then I redirect / to the URL from that custom template.
This is like redirecting say:
/234 to whatever URL you may think of, like say:
http://en.wikipedia.org/wiki/Main_Page

Related

Keep people from opening pdf directly on my webiste

I am not sure if this is possible, but I figure I would ask.
I have hundred of PDF's stored on my website, and they are all getting indexed directly by Google, so people are doing a search and the engine is taking them directly to the PDF. The issue here is that the PDF's are related to language learning and have audios that go with them. If a visitor goes directly to the PDF, then they never see the audios.
I have another page I have designed which opens up the PDF in an Iframe, and shows the audios right next to them so the users can use it.
So my question is, is it possible to redirect a user who opens:
www.mywebsite.com/something.pdf
And have it redirect them to:
www.mywebsite.com/page-with-audios/
The key here is that the pdf should still open in the IFrame on my domain.
Thanks in advance for any assistance.
If you use routing, you could make a route which has the PDF name as parameter. The route could look something like this:
/{PDF_NAME}.pdf
This could be used to match all PDF's, like example.com/foo.pdf, example.com/bar-baz.pdf. Since you then have the name of the PDF they would like to view, you can redirect them to the /page-with-audio-files with some extra data like the name of the PDF. Then you can handle opening the iFrame.
EDIT
since I now see your question was directed at .htaccess, I think the following might work too.
add this rewrite to your .htaccess:
RewriteEngine On
RewriteRule ^([a-zA-Z\-]+.pdf)$ /page-with-audio/$1 [L, R=301]
This will make the $1 variable somepdf.pdf if your request url is http://example.com/somepdf.pdf.
Then it redirects the user to http://example.com/page-with-audio/somepdf.pdf so you know which pdf was requested.

RewriteRule - redirect multi variable URL to multi variable URL

Our old website has a search URL structure like this:
example.com/Country/United States/Region/California/Area/Southern California/City/San Diego/Suburb/South Park/Type/House/Bedrooms/4/Bathrooms/3/
This is currently rewritten to point to the physical page:
/search/index.aspx
The parameters in the URL can be mixed up in different orders, and the URL can include one or more parameters.
We want to 301 redirect these old URLs to a new structure that is ordered in a logical way and more concise:
example.com/united-states/california/southern-california/san-diego/south-park/?type=house&bedrooms=4&bathrooms=3
example.com/united-states/california/?type=house&bedrooms=4&bathrooms=3
Is there a way with URL rewriting to interrogate the old URL, work out what parameters are existing and then write out the new URL structure?
Even if we can limit it to just the Country, Region, Area, City and Suburb, that may be good enough to at least return some results even if it's not perfect.
Also, spaces should be turned into hyphens and all text made lowercase.
I already have the RewriteRule to turn the new URL structure into a URL to point to a physical page. It's just transforming the old URL in to the new URL I need help with. I've googled endlessly and it's just beyond me!
Can anyone help? Thanks.
Since you already have the old search page with rewriting rules set up for it and which is capable of parsing all parameters you need, the easiest and most appropriate solution I see here is to issue a redirect you require from this old search page's code. Just put the code that composes new URL with all parameters needed and redirects from this page - this should be a lot easier than trying to parse all these parameters in .htaccess and combine them into the new format.

Notes 9, rewriting URLs

How do you rewrite a URL in Notes 9 XPages.
Let's say I have:
www.example.com/myapp.nsf/page-name
How do I get rid of that .nsf part:
www.example.com/page-name
I don't want to do lots of manual re-direct because my pages are dynamically formed like wordpress.
I've read this: http://www.ibm.com/developerworks/lotus/library/ls-Web_site_rules/
It does not address the issue.
If you use substitution rules like the following, you can get rid of the db.nsf part and call your XPages directly as example.com/xpage1.xsp:
Rule (substitution): /db.nsf/* -> /db.nsf/*
Rule (substitution): /* -> /db.nsf/*
However, you have to "manually" generate your URLs without the db.nsf part in e.g. menus because the XPages runtime will include the db.nsf part in the URLs if you use for instance the openPage simple action.
To completely control what is going in and out put your Domino behind an Apache HTTP and use mod_rewrite. On Domino 9.0 Windows you can use mod_domino
You can do it with a mix of subsitutions, "URL-pattern" and paritial refresh.
I had the same problem, my customers wants clean URLs for SEO.
My URLs now looks like these:
www.myserver.de/products/financesoftware/anyproduct
First i used one subsitution to cover the folder, database and xpage part of the URL.
My substitution: "/products" -> "/web/techdemo.nsf/product.xsp"
Problem with these is, any update on this site (with in redirect mode) and the user gets back the "dirty" URL.
I solved this with the use of paritial refreshes only.
Last but not least, i uses my own slash pattern at the end of the xpage call (.xsp)
In my case thats the "/financesoftware/anyproduct/" part.
I used facesContext.getExternalContext().getRequestPathInfo() to resolve that URL part.
Currently i used good old RegExp to get the slash separated parameters back out of the url, but i am investigating a REST solution at the moment.
I haven't actually done this, but just saw the option yesterday while looking for something else. In your Xpage, go to All Properties, and look at 'navigationRules' and 'pageBaseUrl'. I think you will find what you are looking for there.

Htaccess redirect and rewrite

I'm trying to get below URL to do a redirect / rewrite
http://www.domain.com.au/posting?id=44404
Below is what is required:
http://www.domain.com.au/state/category/job_title
Is there a way to do this with PHP MySQL Joomla application?
This is using custom component so I have to retrieve state, category and job_title information from MySQL database. Is there a way to insert them into htaccess or recognise so that it reflects on the URL field instead?
Thanks
If you can write a script to get from /state/category/job_title to an id, then you can use a RewriteMap. You can only define a map in either the server config or a vhost config, not in an .htaccess file.
Say you had a perl script that parsed out the state, category, and job_title, did some database lookups, then output 44404 or whatever the id is. Then you can define the mapping like so:
RewriteMap jobmap prg:/path/to/your/script.pl
Then in the htaccess file in your document root, you can use the map:
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /posting?id=${jobmap:$1/$2/$3}
If you wanted to enumerate every state/category/job_title combination, you could also use a text file or a dbm file. Or if you have mod_dbd loaded and configured, you can also use a SQL select query
Another alternative is to write some kind of php script and route everything through that. It would essentially be doing what the script.pl example would do, parse out the state/category/job_title fields, and do the proper database lookup to obtain an id. You could then include the posting script and hand over the id.
This is what you are looking for:
http://www.noupe.com/php/10-mod_rewrite-rules-you-should-know.html
but, as you redirect, your id gets lost
You'll have to write all the codes to replace each id with the needed category state and job title in the .htaccess file, I dont think you can retrieve through mysql and use them to replace in the htaccess file.

CakePHP nice urls - how to prevent normal urls from working

I have a website that's written using CakePHP. I've added some rewrite rules in the .htacces file to change the default urls to different ones (instead of /controller1/action1/parameter I have /some-string-about-controller-and-action/parameter, for example).
The problem is that now both the normal url and the nice one are available, and google seems to be indexing both, which is a problem. I'd like to only keep the nice one, which is the proper way to handle this so that it affects the google results as little as possible?
I don't know why you don't want to use cakes own routing (if you are having trouble doing what you want, you can accomplish what you want with a custom route class), then make sure that you redirect all relevant URL's in your .htaccess file to the desired URL using a MOVED PERMANENTLY redirect.
This way google will index the target url instead of the one that is undesirable. You are right to take offense to this, double indexing is a great way to harm your SEO rankings.

Resources