0

I have a custom content type movie. Now, when I visit any of the movie content, the url is like:

mysite/?q=node/someNumber

I want that every movie content will have url like

mysite/movie/somenumber

or,

mysite/?q=book/someNumber

How to do this?

I am using Drupal 7.

  • Do you have clean URLs enabled? You shouldn't need to enable a special kind of clean URL just for custom content. – Patrick Kenny Apr 22 '12 at 8:01
6

Enable Clean URL + get Pathauto module, which allows to define custom URL patterns for every type of content

If the Clean URL test fails, the web-server is not configured to support this feature. You need to configure the web-server to support Clean URL.

With Apache HTTPD as web-server, you have to enable mod_rewrite and configure the necessary rewrite rules. The rewrite rules can be found in the .htaccess file that comes with Drupal. Usually, theses rules are applied automatically, when mod_rewrite is enabled, but in some cases, the AllowOverride directive is too restrictive to allow this.

See Clean URLs in the Drupal Installation Guide for a more thorough introduction on how to get Clean URLs working in Drupal.

  • i cant enable the clean URL , the test fails – Azad Salam Apr 22 '12 at 14:25
  • What kind of test? where are you enabling the clean URLs? can you paste the URL? (starting with /admin/...) – Artur Apr 22 '12 at 16:17
  • mysite.com/#overlay=%3Fq%3Dadmin/config/search/clean-urls – Azad Salam Apr 22 '12 at 17:05
  • OK, I just wanted to know if we are talking about same admin section. Now, what was it that you tried to do on that page and what was the symptom? – Artur Apr 22 '12 at 17:12
  • When selecting Clean URL option , it asks to "run the Clean URL test", but the test fails – Azad Salam Apr 22 '12 at 17:19
0

Enable Clean URL, then install and enable the Pathauto module, which allows to define custom URL patterns for custom content.

If the "Clean URL test" fails, you need to enable Apache's mod_rewrite.

Usually, it is suffiscient to put this in .htaccess:

RewriteEngine on
RewriteRule ^en/(.*)$ $1

If the above two line don't fix the problem, your web server is not set up to allow rewrite rules. In that case, it is necessary to enable an extension to the Apache web-server known as mod_rewrite. You do this with the following shell command:

sudo a2enmod rewrite

Then navigate to /etc/apache2/sites-available and edit the file named default. Locate the following block of text:

<Directory /var/www>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

And change the AllowOverride directive to:

<Directory /var/www>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all 
</Directory>

When done, restart Apache.

sudo service apache2 restart

(The above example is assuming you're running a standard Apache configuration on Ubuntu ver. 12. YMMV, and you may have to dig out the documentation for your system to see how to do something similar.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.