Drupal .htaccess url aliases - mod-rewrite

How can I make my URL (mysite.com/node/1) appear like this mysite.com/categoryname/myarticlename.html
I've used Joomla! until now, and it has a great option to use mod_rewrite with .htaccess.
How can I do this with Drupal?
Is this possible?
I don't know if I can ask here about these problems, but if not, I will delete this post.
Thanks in advance!

Firstly, make sure you have clean URLs properly configured.
Then you've got two options...
To add aliases on a node-by-node basis, go to the node edit form and add it manually (this is built into core), e.g.
If you want aliases to be automatically created from properties/fields attached to nodes, install the Pathauto, Token and Entity modules (the last of those contains the Entity Token module). Then go to /admin/config/search/path/patterns, and define some aliases for your various content types. e.g.
When you create content an alias will be automatically created. Depending on the settings you choose, the alias can also be updated from the fresh data when you update a node.
As a bonus you can then install Global redirect which will handle all of the auto-301 redirects for you.
Unless you've got a pretty advanced use case you'll never need to edit the .htaccess file just to provide URL aliases.

Related

Change link in Joomla after domain change

I changed the domain of my site (joomla+jfusion+smf)
Some links to smf haven't changed.
In the old site they were
www.olddomain/en/oldforumfolder/
now they are
www.newdomain/en/oldforumfolder/
instead of
www.newdomain/en/newforumfolder/
Is there a way to change them all together?
You can try reReplacer*
*NOTE: This is not the best option.
Better option is, you should use some editor (like TextPad) to locate all the occurrences of the olddomain and replace them with newdomain

Apache2 mixing mod_vhosts_alias and mod_rewrite

The Apache2 docs recommend mod_rewrite as a last resort for specifying which directory to send a given host request to. They said use mod_vhosts_alias. I set that up and its working without problem. However, I have a specific case that entails some mod_rewriting.
I have a domain like mydomain.com and a large number of subnames like sub.mydomain.com and sub2.mydomain.com. These subdomains all map to corresponding directories. But the subdomains will also have full top-level domains that map to respective directories. For instance:
sub.mydomain.com will map to the same directory as awesomeproducts.com sub2.mydomain.com will map to the same directory as widgets.com
What would be the best way to make sure both these methods of accessing each site will work without conflict?
Since the docs only say mod_rewrite isn't as "graceful" as mod_vhosts_alias, I didn't know if I ought to use mod_rewrite completely by itself for my situation or if I should be trying to mix the two approaches somehow.
Is mixing them the way to go or will that create problems?
The behaviors of RewriteRule and RewriteCond change when using mod_vhost_alias. Its been a few days since I tinkered with it so I'm sketchy on it, but watch out for the way RewriteRule interprets the portion of the URL to be rewritten. It may change when using mod_vhost_alias... and RewriteCond behavior might change too.
To accomplish the question I was asking about, I ended up using symbolic links for the actual domains. I setup a bunch of subdomains with associated folders so that sub1.stddomain.com would go to the folder sub1.stdomain.com. Then I added a symbolic link that maps domain1.com to the sub1.stddomain.com folder. That way anyone who visits domain1.com is shown the site in the sub1.stddomain.com folder.
IMPORTANT: After all that work and testing, I ended up going back to to a collection of virtualhost files WITHOUT mod_vhost_alias. Turns out that there is a known problem with mod_vhost_alias. DocumentRoot isn't correctly set when using it. This breaks tons of scripts. It was patched in February 2012 with new special variables and the programming team at Apache dropped the ball. They never wrote any documentation explaining how to use the patch or new variables.
I reopened the issue and stated that its still a bug since you can't write code and not tell anyone how to use it and then call it fixed. Unfortunately the issue had already been ignored for YEARS and it will probably continue to get ignored even though they supposedly wrote code for it.
RECOMMENDED LESSON FROM ALL THIS: Don't use mod_vhost_alias. Write shell scripts to manage your vhost files using one more template files.

magento geolocation redirect

Do you know any plugin that redirects only users to certain store based on the IP (geolocation)?
I have found theese two:
http://www.magentocommerce.com/magento-connect/store-and-currency-auto-switcher.html
http://www.magentocommerce.com/magento-connect/j2t-geoloc-va-automatic-store-and-currency-switch.html
but the problem is that they change also the currency and not only the store.
As an alternative does anyone know a simple coding method to do that? (I should mention that I do not have any knowledge of geolocation so I did not try any coding at all yet)
Thank you,
Mugur
Take a look at your index.php and see how it loads a website/store.
It is relatively simple to install a geoip module on both Apache and Nginx, this module will then enable you to have a $_SERVER value for country code. You can then place a simple php switch/case block in your index.php that sets the website/store values used to call Mage.php and have whatever logic in there to suit your setup.
I don't believe the module route (even if one exists) is what you need given how straightforward it is to write the switch/case for your country->store mappings. You will also need to put in there some extra option for testing purposes, e.g. if the IP address requesting the page is your PC then show whatever store it is you need to test.
Anyway, you can always chose one of Magento's free extensions.
Geo Lock or Geo IP Locations are free and restricted versions of the first extension you linked.

Joomla 1.6 backend admin area blank

For some reason, when I log into my joomla 1.6 backend, it is now empty, displaying only a logout button. Any Ideas?
I just went through the same problem but on J!1.7.3. There may be many, many reasons but please check using just URL if you can see for example:
[YourDomainHere]/administrator/index.php?option=com_content or
[YourDomainHere]/administrator/index.php?option=com_modules
If content is listing and you're missing just Admin-menu and sub-navigation in back-end --> this means you messed-up with access levels and viewing access.
If you can't see content listing - ignore the rest of this post :-)
...with access levels and viewing access. To check that, try entering [YourDomainHere]/administrator/index.php?option=com_users&view=levels and enter each position in the list. Joomla backend navigation module usually has Access set to Special, so focus on this one. When enter Special - manager, author and super administrator should be ticked. If everything empty in any from the list - this is your issue :)
You need to add manager, author and super administrator to your Special access level. Obviously you can't see Save button, so you need to use database. [wrrr :) sounds scary?] Not a big deal, just go there using for example phpMyAdmin and find _viewlevels table. In there just edit Special and add [6,2,8] values to set up manager, author, super.....
Update database. Try to log-in one more time (close browser and clean cache before).
I hope if this wasn't helpful for you, will be for somebody else.
p.s. There may be a way of 'saving' changes in you joomla access levels with URL. Then you don't need to go to DB .. but I don't know if this is feasible at all :)
Check the rewrite of htaccess and the $mosConfig_absolute_path variable in config.php
Apparently, the Bluestork Template (admin template) has some security issues. In my case there were some missing files in the template folder /administrator/templates/bluestork/ that caused the administrator screen to appear blank. I've copied a clean version of the template in the bluestork folder and after that I was able to see the backend admin area.
I've removed the bluestork templates entirely for now, which seems to be the best option. Joomla installs 2.5.8, 2.5.6, 2.5.2, 1.7.0, 1.6.3 are affected. The Blustork Template is a target for hacks with old Joomla.
this happening becoz of admin user lost his permissions. see below article to fix this issue
http://www.codentalk.com/joomla-admin-showing-blank-page/

why my IgnoreRoute does not work?

I want to prevent users access for my "~/Content/..." folder I wrote it as follow in "Global.asax.cs" and put this line of code at the top of every other routes
routes.IgnoreRoute("Content/{*pathInfo}");
but it does not work. in fact user can see every files in content folder by type the URL in browser.
am I missing something?
How did you figure out that it does not work? Give example.
You may have put it last in the Routing table. So try to move it up so that it gets added to the routing table first. The route collection is an ordered list of routes.
Also try this : Routes.IgnoreRoute("Content/");, but your version of ignore is also correct and it should work.
Lastly, I do not know what you mean when you say the user can see all the contents of the Content folder : Isn't that the point? User must be able to download files from the folder, and we usually just need MVC to ignore the requests from coming into the framework, and so that IIS can directly serve those files.
or did you mean Directory browsing is enabled, and you want to disable that : In that case go to IIS manager, and select your website and look for the Directory browsing option and disable it as shown here.
Your problem cannot be solved by routing constraints. There are 3 significant steps in processing request:
IIS got request.
IIS watch at filesystem and search for direct correspondence to file
If IIS didn't found any file - it gives request to ASP.NET MVC for processing.
So, you need to configure folder security to forbidden direct access to files, but allow access to application, as here.
But I don't recommend to secure folder, that should be shared. I don't believe that your site shouldn't have images to display :) If you have some secured content, you need to create another folder.

Resources