6

I installed Drupal 7 on Wamp Server. I can't find any checkbox or link to enable clean URLs; I see only the Run the Clean URL Test button.

How can I enable clean URLs?

13

The settings for the clean URLs are at admin/config/search/clean-urls.
That page shows the "Enable clean URLs" checkbox only when it is possible to enable them; when the server is not configured to support them, that page shows the following message:

Clean URLs cannot be enabled. If you are directed to this page or to a Page not found (404) error after testing for clean URLs, see the online handbook.

On an Apache server, and with the default settings used from Drupal, clean URLs work if:

  • The mod_rewrite module is enabled for the server
  • The following directives are present in the Apache configuration file

    AllowOverride All
    AccessFileName .htaccess
    
  • I needed to alter AllowOverride specifically within this section of httpd.conf: <Directory "/var/www/html"> ----- Not within the <Directory> section – Mark Oct 1 '15 at 14:33
7

Enable the mod_rewrite module then restart the wampserver.

I think you can enable the mod_rewrite from the quick launch icon. Right click and view open the apache modules menu and make sure the mod_rewrite is enabled.

UPDATE:

Open the file httpd.conf inside apache installation folder and edit the following line:

# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
AllowOverride None

To be:

AllowOverride All
  • I cannot find mod_rewrite module in the apache modules. – sjkon Jan 2 '13 at 8:38
  • I had changed the httpd.conf file. But nothing happens. – sjkon Jan 2 '13 at 10:13
  • Disable the apache service and re-enable it. If still no effect, restart your PC. – Muhammad Reda Jan 2 '13 at 10:16
  • I already done these. Any other reason? – sjkon Jan 2 '13 at 10:21
  • doesn't work. There are 3 instances of "AllowOverride" in my httpd.conf. Only 1 can be changed and the sites be served (on restart). Also believe setting ".htaccess" is a red herring: this is default. Possibly you can't actually enable Clean_URLs on a Windoze box with Apache... (?) – mike rodent Jan 17 '15 at 18:01
3

Please enable rewrite_module for apache using wampserver interface.

To access it click on the green "w" icon in systray, go to apache > apache modules > click on rewrite_module.

your wampserver icon should turn red and then orange and green. If not try restarting wampserver. When the icon is green visit the apache modules again and ensure that rewrite_module is checked.

enabling rewrite_module is essentially turning on mod_rewrite, but dont know why wampserver calls it so. Hopefully it solves your issue with clean urls, you can verify its fixed by running the test again.

3

How I solved my problem:

Clean URLS:

  1. Enable the mod_rewrite with this command:

    a2enmod rewrite
    
  2. Then under /etc/apache2/sites-available edit the “default” file and replace Override None with Override All. This needs to be changed twice.

  3. Restart Apache

  • OP wants an answer which applies to Windows OS – mike rodent Jan 17 '15 at 17:55
  • I have the following configuration CentOs 6.7 Drupal 7.39 Just by changing 'AllowOverride None' to 'AllowOverride All' helped me to fix the issue. I have not done 'a2enmod rewrite' – Anil Reddy Oct 12 '15 at 6:59
2

You can use this by .htaccess file

First find this line of code in .htaccess file

#RewriteBase /

and replace it with following line of code:

RewriteBase /~yoursitename/yoursitename

Remove # from the code. Here yoursitename is the folder name after domain name like example.com/~yoursitename/yoursitename.

1

For cleaning URL open Terminal -> Type the command vim /etc/apache2/sites-enabled/000-default

It would open the 000-default file there you would see

<VirtualHost *:80>
ServerAdmin webmaster@localhost

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

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

So select the entire code and put this in place of the code in 000-default file.

<VirtualHost *:80>
ServerAdmin webmaster@localhost

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

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

Now restart the aparche server using

sudo service apache2 restart
  • OP using Windows box (the "W" in WAMPP). Drupal's Clean_URLs seems to be designed to work on Linux. The different platform is therefore the point of OP's post, I believe. – mike rodent Jan 17 '15 at 17:54
0

We need to uncomment or add the line:

LoadModule rewrite_module modules/mod_rewrite.so

to enable mod_rewrite Apache module.

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.