I have navigation uris like this
/pages/index.php?page=gallery
/pages/index.php?page=users
I want to make it so it simply shows the following
/Page/Users
/Page/Gallery
How can I accomplish this, using mod_rewrite, and can you explain me how it works?
Related
I have a site on a subdomain (www.website.com/foobar) which pulls the default page view. Due to the nature of MVC apps, this default page view can also be reached through the "controller/action" URL of the default content (www.website.com/foobar/{controller}) and (www.website.com/foobar/{controller}/{action}).
For the sake of analytics and tracking, I would like any of these other URLs, besides the original short (www.website.com/foobar), to redirect back to this shorter URL.
So...
www.website.com/foobar/{controller}, when typed in, or clicked on in a bookmarked link, should redirect to www.website.com/foobar
I've tried playing around with the routing, but couldn't get anything to actually change the URL itself. I'm not sure if it's possible to change through mapping.
Edit: Has anyone used the HTTP Redirect within IIS7? I can redirect from the top tier, but cannot seem to get the redirect to work on any of the Views.
I don't think you can use routing alone to redirect up a domain. I had a similar issue and after a few days of searching and asking around, I ended up using Redirect itself to get over the issue. Hope this helps.
I was able to solve the problem in IIS 7 by using the HTTP Redirect module. Because it's an MVC application it was a little trickier to setup a redirect on a view, but it's possible. I used this tutorial: Creating a redirect in IIS7
Edit: While the above solution works, it tended to be unpredictable. I ended up solving it by reading the URL the user was inputting in the Index action of the Quote controller, and then redirecting if keywords I was looking for were in the URL. Just a simple if statement at the beginning of the Index action.
I am looking for a way of replicating what the site in the title of this question does. That is, via ajax, changing a part of the page. But, I could not figure out how to change the URL as these things happen.
So, please, help me achieve the effect of url changing on ajax page/change.
Thank you.
(edit ** question rewritten as is appears it was not written well enough, sorry)
What you are looking for is AJAX basically updating only parts of a HTML page. Please google for AJAX tutorials. Here is a simple one
Something like Jquery Tabs also do this.
It seems like you want the URL to change. This is the basic trick to have history for ajax pages
I am starting to set up a personal website, and I would like it's layout to look something like
-------------------------------
- Page Header & Menus Go Here -
-------------------------------
- Main Contents -
-------------------------------
- Footers -
-------------------------------
The main question is that I would like it to be a single-page interface in which the main contents are loaded and displayed with a combination of AJAX and jQuery to produce a nice effect. However, I would, of course, like to have the contents bookmark-enabled and indexed by search engines. I have skimmed throught the Single Page Interface Manifesto which explains some nice ways of achieving this, but I wouldn't really like to have my URLs like
http://www.mysite.com/index.php#!section=section1
http://www.mysite.com/index.php#!section=section2
I would, of course, like to re-write them as
http://www.mysite.com/section1
http://www.mysite.com/section2
My questions are this whether this approach is correct/doable and if AJAX URLs are compatible with URL rewriting. What URLS would be indexed by, say, Google anyway?
If you want your page to work without reloading and update at the same time the page's URL, the only way to archieve this is by changing the hash in the URL (location.hash = 'whatever').
URL rewriting cannot be used since the hash is not sent to the server, it's only available in the browser's scope.
Check Facebook or Twitter URLs. They are prettier than #!section=section1 but still need the hash.
Cheers.
If you want to load different content/tabs/some content of page without reloading browser,
Now It is possible with pjax..
you can use something like http://padrino-pjax.heroku.com/
you can try it, go to the link and click on any of links home,dinosaurs,aliens
and you will see It will change url and some content without reloading full page
It is achieved using ajax+push/pop of url in browser
I'm looking for a solution myself for a similar problem (I have a client site with an AJAXed wordpress theme, and these dreadful #! stuff on the URL prevent all the Social sharing plugins I have tried so far, from working correctly).
Apparently, there is a solution (with some drawbacks ofc..). I found about it here: http://moz.com/blog/create-crawlable-link-friendly-ajax-websites-using-pushstate
I know it's like two years since you've asked, but it could be helpful for someone else, or you may wanna check it out just for the sake of the curiosity itself! :-)
I have created a controller named «wizard» that should get a parameter and then, depending on this parameter, do this thing or another thing.
I can do this easily with the url http://mysite.com/wizard/index/index/action/cutting. That should give the action parameter with the value «cutting» to my indexAction of my IndexController.
But what I'd really want is to have the same thing but with the url:
http://mysite.com/wizard/cutting
Where «cutting» is the parameter. If I want to handle this with my indexAction of my IndexController.php, what should I change on the config.xml? (well, I'm supposing that I can set this on the config.xml file, but don't know how).
Btw: I know I can pass something like ?action=cutting, but that's not what I want...
Thanks!
You have to enable mod_rewrite on your server (if you are using apache) and enable "Use web server rewrites"
Here's a good tutorial explaining the issues.
When it comes to URL Rewriting there are some alternatives these days like the IIS7 module or Urlrewriter.NET. However, as far as I can see those two are based on wildcards which I sadly cannot use.
My problem is that the data I'm working with have no real structure. A made up example:
Something.aspx?page=4 might be /Weapons/Flails/
Something.aspx=page=5 might be /Clothes/Dresses/Blue/
i.e. there is no clear match between page id and what kind of page it is pointing to. I guess this requires some kind of lookup (slugs?) in a db.
How would I implement this in the easiest way? Does any of the existing alternatives offer a solution to this or do I have to build my own module?
Thank you.
IIS7 had a regular Expression option not just wild card it also has Rewrite maps. which i think is what you are looking for, it could be your look up table.
when you set up a rewrite rule, use the drop down to find the regEx option.
also when you create the rule, the option for the map is there.
You can also use the Managed Fusion URL Rewriter and Reverse Proxy. It support the Apache mod_rewrite sytnax of configuring rewriting. And you can use this method described on my blog to create a module that can do a database lookup of these old ID's and redirect them to the correct location.
http://www.coderjournal.com/2008/12/creating-extension-module-net-url-rewriter-reverse-proxy/
Please contact me through my blog if you would like help setting up this type of rewriting.