I want to use Url-Mappings to transform the url.
"/blog/$system?"(controller:"blog", action:"home")
What I want to achieve is
"/blog/bob"
should become
"/blog/home?system=bob"
It doesn't seem to work as I excpected. What is my misunderstanding? Can I get this done? How?
remove the mapping, then Grails will use the default one:
"/$controller/$action"()
which in your case would be
/blog/home?system=bob
Related
I'm ready to scream how hard can this be? I've been trying for too long.
If I have http://www.example.com/more/pages/page.php or similar I want to be able to get
www.example.com.
Thats all. So I can use it as I please. This will of course change if on production or development so I want to ascertain it dynamically.
Request::root()
returns http://www.example.com/more/pages/page.php
URL::to('/')
returns http://www.example.com/more/pages/page.php
How do I get this? Why am I having so much trouble to do this??
UPDATE (2017-07-12)
A better solution is actually to use Request::getHost()
Previous answer:
I just checked and Request::root(); does return http://www.example.com in my case, no matter which route I'm on. You can then do the following to strip off the http:// part:
if (starts_with(Request::root(), 'http://'))
{
$domain = substr (Request::root(), 7); // $domain is now 'www.example.com'
}
You may want to double check or post more code (routes.php, controller code, ...) if the problem persists.
Another solution is to simply use $_SERVER['SERVER_NAME'].
You also may test any of these:
Request::server ("SERVER_NAME")
Request::server ("HTTP_HOST")
It seems better than making any treatment of
Request::root()
All right.
In Laravel 5.1 and later you can use
request()->getHost();
or
request()->getHttpHost();
(the second one will add port if it's not standard one)
My hint:
FIND IF EXISTS in .env:
APP_URL=http://yourhost.dev
REPLACE TO (OR ADD)
APP_DOMAIN=yourhost.dev
FIND in config/app.php:
'url' => env('APP_URL'),
REPLACE TO
'domain' => env('APP_DOMAIN'),
'url' => 'http://' . env('APP_DOMAIN'),
USE:
Config::get('app.domain'); // yourhost.dev
Config::get('app.url') // http://yourhost.dev
Do your magic!
This is for Laravel 5.1 and I am not sure does it work for earlier versions but if somebody search on Google and lands here it might be handy in middleware handle function gets $request parameter:
$request->server->get('SERVER_NAME')
outside of middleware handle method you can access it by helper function request()
request()->server->get('SERVER_NAME')
use directly where you want controller or web.php
Request::getHost();
I think you can use asset('/')
is there a possibility to encrypt or just don't display the Get Parameters in the Internetbrowser when im using JavaServlets on Tomcat?
that means for example: localhost/main?id=3
should be displayed like this: localhost/main or localhost/main?6puu4YjzScxHsv9t....
Is there a simple and fast solution? Does this make sense?
Thx for your tips..
You could use POST instead of GET on your HTML form. This will turn localhost/main?id=3 into localhost/main. The parameter id will still be passed and you should be able to retrieve its value in the same way, on the server-side.
Is there a way to make the tag name on acts_as_taggable_on to be URL friendly?
For example, at the moment I have 'tags/foo' and 'tags/bar' working great. However when I add spaces to the name such as 'rabbits foot' the url is 'tags/rabbits%20foot'. I'd like to replace that %20 with a dash.
Thanks in advance!
UPDATE
I just noticed that stackoverflow actually uses a very similar or identical way of doing tags to what I have in mind.
Take a look at this
https://github.com/arturaz/acts_as_taggable_on_steroids
It has a way to change the multiple words into a slug (e.g. rabbits foot into rabbits-foot), there's also manual non plugin ways to do this as well (it looks somewhat outdated).
Decided to kind of cheat and use the id+tag.name just to get passed this hump for now. Will revisit when I have more time.
i want to pass a parameter in url blank but localhost server tell that it is bad url. are i can make them work in MVC 3
the url is
http://localhost:6251/time/saturdau/first/second//nextparameter
you can see that third parameter is blank here. are this request can work whenever 4th parameter pass without passing 3rd paramter.
what i do to make this work.
rather put a work around on this say you make a convention if the parameter passed is null you may try passing something like my_conventional_null_indicator
so instead of making it look like this
http://localhost:6251/time/saturdau/value1/34//70
do this
http://localhost:6251/time/saturdau/value1/34/my_conventional_null_indicator/70
but the best way would still be the conventional way
http://localhost:6251/time/saturdau?param1=value1¶m2=34¶m3=¶m4=70
or the much better way is to maximize the capability of the RouteValueDictionary.
This is not allowed. You can have optional parameters, but they must be the last segment in the URL. You can't have an optional parameter in the middle.
I think this is an easy question. I am using this useful Flash Document Reader called FlexPaper. I have it embedded in one of my Show pages. But when I click the a link on their tool bar to show the document in a new browser, it points to the following link:
http://example.com/intels/FlexPaperViewer.swf?ZoomTime=0.5&FitPageOnLoad=false&PrintEnabled=false&SwfFile=%2FPaper.swf
which doesn't work, I get the following error:
ActiveRecord::RecordNotFound in IntelsController#show
Couldn't find Intel with ID=FlexPaperViewer
but if I remove the "intels" from the path so the url looks like:
http://example.com/FlexPaperViewer.swf?ZoomTime=0.5&FitPageOnLoad=false&PrintEnabled=false&SwfFile=%2FPaper.swf
It works fine.
My question is what is the best way to handle this? Can you write a route that rewrites a url that starts with intels/FlexPaperViewer.swf and remove the intels prefix? What would that look like?
Is there a better option?
Juat a thought, how about placing the FlexPaperViewer.swf inside public/intels folder?
So the directory structure will be
<project-directory>/public/intels/FlexPaperViewer.swf
Doing this will make the link correct. It seems to be easier to do it this way.
Hopefully it helps.
EDIT
Another alternative will be to see how the link was generated, maybe there is a parameter that you can set when you embed the FlexPaper.
I am not aware of any route modification that can do what you want. Maybe someone else can help on this.