I want to Install a drupal website on the server in a subdirectory to use some of it's features for my main website, I dont want the installation affect the current website in any way.
the actual reason for doing this is that for example I would be able to use news section of drupal for main website.
so for instance, I install drupal on "drupal" subdirectory like www.mydomain.com/drupal , then when I configure and run the news section it will be like www.mydomain.com/drupal/news, what I want is when a user goes to www.mydomain.com/news, it loads www.mydomain.com/drupal/news instead.
I'd really appreciate any proper approach and suggestions to achieve this.
If I correctly understand your question that you want to have URLs like:
http://example.com/news/headline-test
But using Drupal's URL http://example.com/drupal/news/headline-test to provide the content of the first URL, you should use Apache rewrites.
Here is an example:
Add this to your top .htaccess folder (http://example.com/.htaccess - not publicly accessible yes):
RewriteEngine on
RewriteRule ^news/(.*) drupal/news/$1
See the Apache rewrite document for more examples/help.
Drupal cannot take over any folder if there is another file exists or it's pointing to another folder. But in this case, both of your http://example.com/drupal/news/headline-test and http://example.com/news/headline-test URLs will show the same content.
Do not edit Drupal's $base_url setting. Let Drupal figure it out. Also, add some robots.txt disallows to prevent content duplication. Block drupal's native URLs.
Take a look at redirect module.
OR
Create a custom module with hook_menu implementation
function MY_MODULE_menu()
{
$items = array();
$items['news'] = array(
'title' => 'news redirect',
'type' => MENU_CALLBACK,
'access callback' => TRUE,
'page callback' => 'drupal_goto',
'page arguments' => array('drupal/news'),
);
return $items;
}
Related
I am able to reach my website at a certain ip address and I am going to implement a REST service. I have some PHP files that perform actions on a database and I am calling them from the client. I am using linux ubuntu as server and so far I can do this:
http://xxx.xxx.xxx.xxx/api/create/?id=someId&val=someValue
http://xxx.xxx.xxx.xxx/api/delete/?id=someId
I can do the above because inside /var/www/html I have a folder called api that contains another folder called create. The create cointains the file index.php so that I can omit it and execute the URL you can see above.
This works fine but I don't think this is the proper way to do it. I am new with this so I don't know what to do. After some researches I have found that my goal probably be achieved using an .htaccess file use url rewriting but I am not sure.
How can I do this? Do I have to place all the php files in a single folder and then use an htaccess file? (^)
(^) To be more precise: instead of having this
http://xxx.xxx.xxx.xxx/api/create/index.php?id=someId&val=someValue
http://xxx.xxx.xxx.xxx/api/delete/index.php?id=someId
//and so on with other actions...
Do I have to create a folder like
http://xxx.xxx.xxx.xxx/files/
containing all my php files (create.php, delete.php, view.php...) and the use an htaccess to redirect?
I see that websites offer their api using www.domain.com/api/something/?data=Value or www.domain.com/api/something/dataAbout/. Are they doing what I have said about the .htaccess? I hope I have well explained my problem.
htaccess:
RewriteEngine On
RewriteRule ^api/([\w-]+)/?$ files/$1.php [L,NC]
This is inside /var/www/html and I have api inside /home/username/api .
Thanks Emma
Do it like this:
Create php files in a folder files/ subdirectory as create.php, delete.php, view.php etc (by renaming each individual index.php file, you mentioned).
Move away api directory somewhere outside site root.
Once that is done use following .htaccess file in /var/www/html/:
RewriteEngine On
RewriteRule ^api/([\w-]+)/?$ files/$1.php [L,NC]
Then use new URLs as:
http://xxx.xxx.xxx.xxx/api/create?id=someId&val=someValue
http://xxx.xxx.xxx.xxx/api/delete?id=someId
In first, this is not the right way to create a RESTFUL API. My suggestion is to you read a best practices article.
You shouldn't create a CREATE and DELETE folder. You should use HTTP actions.
To create a new record you should use POST. In example, POST /user and in the body you pass the user's information.
In another example, you could use the same route by using different HTTP methods: DELETE /user/1 to delete a user and PATCH /user/1 to edit some already existent user's information.
Hope it's help you.
I am using Yii framework to develop my website. I didn't activate any URL manager in my main.php file and every thing is working fine with the default url structure. But now i want get the data of user from the below url manner
www.projectname.com/username.
But as per the current url structure, i am unable to get the data and it is showing requested url not found on this server.
When I type www.projectname.com/index.php/username then it is working but users will not enter index.php and it is not good manner as i know.
So can anyone please guide me to get the data when the user enter the url like
www.projectname.com/username
If your Username Controller Then
Use This In your config main.php
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
'<username>' => 'user/profile',
You need to remove index.php from the url. You can follow this link to learn how to do it.
My new Ember-CLI app uses a user portal slug in the URL to display proper information to the user. For example (fake URL): http://my.server.portals.com/robertplant
I'm using a combination of router and adapter logic to get the user portal name form the url slug, and then display the data related to it. It probably needs some more work, but here's what I have so far:
Router code extract:
Router.map(function () {
this.route('portal', {path: '/:portal_slug'}, function () {
this.resource('account', {path: '/'});
});
});
Adapter code extract (for hitting the right API end point based on portal):
namespace: function () {
var portal = window.location.pathname.match(/^\/([^\/]*).*$/)[0];
return 'abc' + portal + '/api/v1';
}.property().volatile(),
I can hit the app locally (e.g.: http://localhost:4200/robertplant/) with no issues. It runs using Ember-CLI’s built in web server.
However, when I move the app to the server, which runs Apache, and try to hit it (e.g.: http://my.server.portals.com/robertplant), I get:
Not Found
The requested URL /robertplant was not found on this server.
Which makes sense I suppose, since there isn’t really a directory named the same as the slug. However, there has to be a way, I would think, to tell Apache to ignore the problem it thinks it is having, and allow the app router to handle it. The local web server is doing it somehow.
Ideally, the solution would leave the URL displayed the same. Also, re-writing the request to point to something like http://my.server.portals.com?slug=robertplant causes Ember-CLI assets to be looked for at the wrong path (can't set baseUrl dynamically).
I'd appreciate any feedback on how to set up the app in Apache to allow for this to happen.
Solution:
Say the current subdomain is my.portal.com. Create another subdomain that points to the same directory on the server. Name it my2.portal.com
For the first subdomain, add a mod rewrite rule which rewrites something like
http://my.portal.com/joe_blow
as
http://my.portal.com?portal_slug=joe_blow
This allows you to hit the url without a 404.
Set the asset paths (in the generated index.html) to point to the second subdomain. E.g.:
http://my2.portal.com/assets/app_name.js
This allows the app to find the assets without the issues associated with the rewrite or the slug in the url.
Of course, you can also place the assets anywhere else, including an S3 bucket. But in my case, I have a constraint of having to store them on the same server/network for security reasons. And my way you can deploy all the files to the same location.
That's it! Works like a charm.
The only thing I'm not fond of, is having to edit the index file after it's generated. I will try to automate it at some point.
I made an application in Joomla 3. Had a custom component in front end, which showing the details of a selected category.
Which the URL with out enable search engine friendly and URL rewrite as follows
wwww.sitename.com/index.php?option=com_arts&view=category&id=12
So I enabled the URL rewrite, SEO URL and URL suffix
http://www.sitename.com/component/arts/12.html?view=category
But I am trying to get a URL like this
http://www.sitename.com/caterory/12
I generated the link to this page using
<?php echo JRoute::_('index.php?Itemid=115&id='.$cat->id); ?>
Can anyone please help
Thanks in advance
To make the SEF router do what you want it to do, you have write your own router. You cannot, however, get rid of the component part of the URL.
Do do that, you do not need your own router, but a menu entry for each category. That menu does not have to be displayed, if you don't want to show it. The alias of that menu entry is then used for the SEF URL.
I think, this is what you are looking for
Supporting SEF URLs in your custom component
sef urls for custom component, which variant is better?
I'm making a website on yii which has several separate parts, each on it's own subdomain like themes.example.com, events.example.com etc with main page example.com where these parts are listed. I will also need to authenticate users across subdomains. So i'm thinking what would be better: making each part as a yii module or making a separate yii application for each of these parts?
I think in your case it would be better to use modules. At least to have a single webroot directory. Using separate yii application would be appropriate for console part of your project.
See this link for more information: The directory structure of the Yii project site
Well,
The features you are trying to accomplish from Yii its called "Parameterizing Hostnames". You need to create a module based structure in Yii.
At first you need to create a virtual host from apache and redirect that to your Yii project. On you Yii framework you need to change the URL manager from config.
'components' => array(
...
'urlManager' => array(
'rules' => array(
'http://admin.example.com' => 'admin/site/index',
'http://admin.example.com/login' => 'admin/site/login',
),
),
...
),
To know more about Parameterizing Hostnames