In TYPO3 < 9 it was possible to set conditions in typoscript using query parameters like this:
// Set a condition when news extension plugin parameter "news" is set, e.g. url:
// www.mysite.com?tx_news_pi1[news]=8
[globalVar = GP:tx_news_pi1|news > 0]
...
[global]
with realurl you could rewrite the url to a pretty url and the above condition stil worked.
Now, in TYPO3 9 i don't use realurl anymore to rewrite the url, but the native rewriting module.
The condition does not work anymore.
As well using the new new symphony query language conditions does not work here:
[request.getQueryParams()['tx_news_pi1']['news'] > 0]
...
[global]
I debugged the request condition code, there are no query parameters.
But in the news controller they arrive.
Question is:
How can I set a condition like above to respond to extension query parameters in TYPO3 9 using the native url rewriting?
The old TYPOscript condition can be rewritten with this, but your example should work as well:
[traverse(request.getQueryParams(), 'tx_news_pi1/news') > 0]
...
[END]
See changelog.
According to different configurations for news urls, you can set the limitToPages parameter in the sites YAML file, since there is no ext:realurl anymore:
Example:
routeEnhancers:
NewsPluginOne:
type: Extbase
extension: News
plugin: Pi1
limitToPages: [20]
routes:
...
NewsPluginTwo:
type: Extbase
extension: News
plugin: Pi1
limitToPages: [21]
routes:
...
With the above configuration you set different settings for the news url on the detail page with the id=20 and id=21.
Related
I'm trying to add a Cloudflare URL Rewrite Transform Rule so that users that come to my blog using this link: "https://example.com/myfirstblog" (dynamic path) get redirected to "https://example.com/?blogPage=myfirstblog"
I've tried looking at the docs and using this in the expression editor, but to no avail.
(http.request.uri.path ne "" and not http.request.uri.path contains "/static")
I'm trying to dynamically define a version in the URI routing.
My immidiate ideas were to
a)
I've configured in the application.conf a row stating my current version:
myApp.ver = 0.1
I wan't to use it in the routes file as part of the URI, for example:
GET /myApp/{version}/welcome controller.myApp.Welcome()
The idea is not to pass the version number to the Welcome() method
but to get the version from the application.conf file.
I've searched for defining parameters in the route file but didn't find information that helped me.
b) Another idea was to have a variable in the routes, something like:
CurrentVersion = 0.1
in the routes file and use it in the URI.
How can I solve this? I havn't found an example for this.
Thanks.
If you want to do this for every route, it should be possible to set the application.baseUrl to include your version number. To do this conveniently you can define the version in your application.conf instead of the Build.scala file, as described here.
myApp.name = myApp
myApp.ver = 0.1
application.baseUrl = ${myApp.name}/${myApp.ver}
If you want to do it only for some routes, there doesn't seem to be a simple solution. If you could ignore parameters in routes, I'd say use a regexp parameter and verify it in your global router - unfortunately this doesn't seem possible without passing the parameter to the controller.
So I see two other options:
Hardcode the version number in the routes file and do a search and replace every time it changes.
Create a plugin for the sbt build process and let it replace the version in your routes file.
In Play 1.2.x, in your conf/routes file, add a route like this:
GET /myApp/${play.configuration.getProperty("myApp.ver")}/welcome myApp.Welcome()
How can I convert these URL to SEO friendly URL I tried Url manager in yii but didn't get the proper result is there any good tutorial regarding url manager
http://localhost/nbnd/search/city?city=new+york
http://localhost/nbnd/search/manualsearch?tosearch=Hotel+%26+Restaurants+&city=New+york&yt0=Search&searchtype=
I tried to the following setting in url manager
'<controller:\w+>/<action:\w+>/<city:\d>'=>'<controller>/<action>',
which works with url http://localhost/nbnd/search/city/city/Delhi
I wish to reduce this url to http://localhost/nbnd/search/city/Delhi
and the link I generating in my view is <?php echo CHtml::link(CHtml::encode($data->city), array('/search/city', 'city'=>$data->city)); ?>
This generates link as http://localhost/nbnd/search/city?city=Delhi
How can I convert that link to like http://localhost/nbnd/search/city/Delhi
The rule should be (to remove the extra city, which is the GET parameter name):
'<controller:\w+>/<action:\w+>/<city:\w+>'=>'<controller>/<action>', // not city:\d, since Delhi is a string, not digit
So the rule should be able to match the parameter name, incase you had foo/Delhi, you'd use <foo:\w+>.
And to remove the ? use appendParams of CUrlManager, (in your urlManager config):
'urlManager'=>array(
'urlFormat'=>'path',
'appendParams'=>true,
// ... more properties ...
'rules'=>array(
'<controller:\w+>/<action:\w+>/<city:\w+>'=>'<controller>/<action>',
// ... more rules ...
)
)
When appendParams
is true, GET parameters will be appended to the path info and separate from each other using slashes.
Update: Incase you have more than one parameter being passed to the action i.e:
http://localhost/nbnd/search/manualsearch/Delhi?tosearch=restaurants
Use a /* at the end of the rule:
'<controller:\w+>/<action:\w+>/<city:\w+>/*'=>'<controller>/<action>'
To get urls of form:
http://localhost/nbnd/search/manualsearch/Delhi/tosearch/restaurants
In Yii we can create urls dynamically For eg.
$url=$this->createUrl($route,$params);
$route='post/read'.
$params=array('id'=>100)
we would obtain the following URL:
/index.php?r=post/read&id=100
To change the URL format, we should configure the urlManager application component so that createUrl can automatically switch to the new format and the application can properly understand the new URLs:
array(
......
'components'=>array(
......
'urlManager'=>array(
'urlFormat'=>'path',
),
),
);
WE will obtain this
/index.php/post/read/id/100
You can refer this link for user friendly urls in yii
http://www.yiiframework.com/doc/guide/1.1/en/topics.url
I'm pretty new to Zend Framework and I'm building a website hoping to implement good SEO practices.
The URL structure will be:
example.com/language/city/controller/action
So I've created this route in my bootstrap:
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$route = new Zend_Controller_Router_Route(':language/:city/:controller/:action/*',
array('language'=>'es',
'city'=>'barcelona',
'controller'=>'index',
'action'=>'index'));
$router->addRoute('language_city', $route);
Which I'm not sure is OK but seems to do the trick.
What I notice next is all these URLs point to the same content (bad SEO practice):
/
/es
/es/barcelona
/es/barcelona/index
/es/barcelona/index/index
Is there a way to get around this duplicated content problem?
Thanks in advance!
You're setting the defaults, so for exactly one page (the default page) the request will be the same. It you removed the defaults, you'll get an error (404 I believe) if the URI doesn't contain the variable.
$route = new Zend_Controller_Router_Route(
':language/:city/:controller/:action/*',
array('language'=>'es', //default when not in URI
'city'=>'barcelona', //default when not in URI
'controller'=>'index', //default when not in URI
'action'=>'index' //default when not in URI
)
);
It seems like you may want to remove the defaults for language city, since without that data I'm not sure what your controller is going to do.
If you did that, the only 'duplicated' URIs will be:
/es/barcelona
/es/barcelona/index
/es/barcelona/index/index
But you only have to use one of those URIs. If you output links using Zend's View_Helper_Url, it'll drop the index/index off - since it matches the default value.
You can always add additional routes to map other requests (say /) to the relevant controller.
It should also be noted, if you only have a single controller handling all these 'city' requests, you don't need to put it on the URI:
$route = new Zend_Controller_Router_Route(
':language/:city/:action/*',
array('language'=>'es', //default when not in URI
'city'=>'barcelona', //default when not in URI
'controller'=>'index', //all requests route here
'action'=>'index' //default when not in URI
)
);
Then the only 'duplicate' URIs are:
/es/barcelona
/es/barcelona/index
I've got a small CMS system written in PHP and running on Apache. The format of the URLs this CMS system uses/generates is:
/display.php?PageID=xxx where xxx is just some integer number. As you can see, those URLs are not very friendly, neither for users nor search engines.
I believe that using mod_rewrite (or something like that) and .htaccess files I should be able to configure Apache for URL-rewriting. I have searched for information about this before but I did not find any easy method to do this, it always involved messing with regular expressions, which I'm not very familiar with.
Since the website in question is really simple and small, just 5-10 different pages, I would really like to be able to just hard-code the configuration, without any special rules or regexps.
I'd just like to map a friendly URL to an actual URL, perhaps like this:
/about = /display.php?PageID=44
/products = /display.php?PageID=34
etc.
Is it possible to configure the mod_rewrite plugin in a basic way like this?
Could someone explain the easiest method to do this? Explain it to me as if I was a child :-)
Thanks in advance!
well putting something like
RewriteEngine on
RewriteRule ^about$ ./display.php?PageID=44
RewriteRule ^products$ ./display.php?PageID=34
in your .htaccess-file shouldn't be the big deal I think...
URL Rewriting for Beginners is my favorite intro article to this, it should cover what you're looking for. In fact, the first actual example where you write a .htaccess file is almost identical to what you want.
Another way is filter by a dynamic php file with a mapping for pages or a routing strategy like frameworks like drupal code igniter ....
and your URL will be like
my-pages/about.html -> display.php?PageID=44
my-pages/products.html -> display.php?PageID=34
and so on
Here a suggestion for .htaccess file and the filter the action with this strategy
--- .htaccess file ----
*RewriteEngine on
RewriteRule ^my-pages/(.).html$ MY-URL.php [QSA,L,E]
---------------- MY-URL.php ---------
<?php
$PREFIX = 'my-pages/'; //--- not used
$mapping=array(
'about' => 44,
'products' => 34
);
$pathinfo= pathinfo( $_SERVER['REQUEST_URI'] );
/* $pathinfo['dirname'] -> my-pages
$pathinfo['basename'] -> ???.html
$pathinfo['extension']-> .html
*/
$page = substr( $pathinfo['basename'] ,0,-5);
if( isset( $mapping[$page] ){
// ---- redirect or include
YUOR CODE HERE
}
else {
//--- error 404
YUOR CODE HERE
}
?>